diff options
author | Lucas Dupin <dupin@google.com> | 2019-09-09 14:06:55 -0700 |
---|---|---|
committer | android-build-team Robot <android-build-team-robot@google.com> | 2019-09-20 02:57:52 +0000 |
commit | c31a6a1188cc036c39ed886ed10951e435a27b9f (patch) | |
tree | d3a9099892cda76d91f8e90643ae843d7031a358 | |
parent | f10afbaab2204c623c7623719e4cd2aff1b9b68f (diff) | |
download | base-c31a6a1188cc036c39ed886ed10951e435a27b9f.tar.gz |
Fix issue where notif wouldn't HUN
DozeSensors and DozeTriggers have code that perform proximity
checks in slightly different ways. DozeSensors was updated as
part of ag/9185335 bug DozeTriggers wasn't.
Bug: 9185335
Fixes: 140701062
Bug: 138765669
Test: partially cover prox, send notification, look at screen
Change-Id: Ic85181abb3edd4c77c427faefa4cd6b9c35b498f
Merged-In: Ic85181abb3edd4c77c427faefa4cd6b9c35b498f
(cherry picked from commit 19ef3004c16f7fa572b98a5c3755fedcfc407410)
-rw-r--r-- | packages/SystemUI/src/com/android/systemui/doze/DozeTriggers.java | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/packages/SystemUI/src/com/android/systemui/doze/DozeTriggers.java b/packages/SystemUI/src/com/android/systemui/doze/DozeTriggers.java index 00bfb3f7cae8..bab64db4519c 100644 --- a/packages/SystemUI/src/com/android/systemui/doze/DozeTriggers.java +++ b/packages/SystemUI/src/com/android/systemui/doze/DozeTriggers.java @@ -417,6 +417,9 @@ public class DozeTriggers implements DozeMachine.Part { mDozeSensors.dump(pw); } + /** + * @see DozeSensors.ProxSensor + */ private abstract class ProximityCheck implements SensorEventListener, Runnable { private static final int TIMEOUT_DELAY_MS = 500; @@ -428,6 +431,7 @@ public class DozeTriggers implements DozeMachine.Part { private boolean mRegistered; private boolean mFinished; private float mMaxRange; + private boolean mUsingBrightnessSensor; protected abstract void onProximityResult(int result); @@ -435,6 +439,7 @@ public class DozeTriggers implements DozeMachine.Part { Preconditions.checkState(!mFinished && !mRegistered); Sensor sensor = DozeSensors.findSensorWithType(mSensorManager, mContext.getString(R.string.doze_brightness_sensor_type)); + mUsingBrightnessSensor = sensor != null; if (sensor == null) { sensor = mSensorManager.getDefaultSensor(Sensor.TYPE_PROXIMITY); } @@ -453,6 +458,9 @@ public class DozeTriggers implements DozeMachine.Part { mRegistered = true; } + /** + * @see DozeSensors.ProxSensor#onSensorChanged(SensorEvent) + */ @Override public void onSensorChanged(SensorEvent event) { if (event.values.length == 0) { @@ -462,7 +470,14 @@ public class DozeTriggers implements DozeMachine.Part { if (DozeMachine.DEBUG) { Log.d(TAG, "ProxCheck: Event: value=" + event.values[0] + " max=" + mMaxRange); } - final boolean isNear = event.values[0] < mMaxRange; + final boolean isNear; + if (mUsingBrightnessSensor) { + // The custom brightness sensor is gated by the proximity sensor and will + // return 0 whenever prox is covered. + isNear = event.values[0] == 0; + } else { + isNear = event.values[0] < mMaxRange; + } finishWithResult(isNear ? RESULT_NEAR : RESULT_FAR); } } |