Merge "Fix issue where notif wouldn't HUN" into qt-qpr1-dev
This commit is contained in:
@@ -417,6 +417,9 @@ public class DozeTriggers implements DozeMachine.Part {
|
|||||||
mDozeSensors.dump(pw);
|
mDozeSensors.dump(pw);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see DozeSensors.ProxSensor
|
||||||
|
*/
|
||||||
private abstract class ProximityCheck implements SensorEventListener, Runnable {
|
private abstract class ProximityCheck implements SensorEventListener, Runnable {
|
||||||
private static final int TIMEOUT_DELAY_MS = 500;
|
private static final int TIMEOUT_DELAY_MS = 500;
|
||||||
|
|
||||||
@@ -428,6 +431,7 @@ public class DozeTriggers implements DozeMachine.Part {
|
|||||||
private boolean mRegistered;
|
private boolean mRegistered;
|
||||||
private boolean mFinished;
|
private boolean mFinished;
|
||||||
private float mMaxRange;
|
private float mMaxRange;
|
||||||
|
private boolean mUsingBrightnessSensor;
|
||||||
|
|
||||||
protected abstract void onProximityResult(int result);
|
protected abstract void onProximityResult(int result);
|
||||||
|
|
||||||
@@ -435,6 +439,7 @@ public class DozeTriggers implements DozeMachine.Part {
|
|||||||
Preconditions.checkState(!mFinished && !mRegistered);
|
Preconditions.checkState(!mFinished && !mRegistered);
|
||||||
Sensor sensor = DozeSensors.findSensorWithType(mSensorManager,
|
Sensor sensor = DozeSensors.findSensorWithType(mSensorManager,
|
||||||
mContext.getString(R.string.doze_brightness_sensor_type));
|
mContext.getString(R.string.doze_brightness_sensor_type));
|
||||||
|
mUsingBrightnessSensor = sensor != null;
|
||||||
if (sensor == null) {
|
if (sensor == null) {
|
||||||
sensor = mSensorManager.getDefaultSensor(Sensor.TYPE_PROXIMITY);
|
sensor = mSensorManager.getDefaultSensor(Sensor.TYPE_PROXIMITY);
|
||||||
}
|
}
|
||||||
@@ -453,6 +458,9 @@ public class DozeTriggers implements DozeMachine.Part {
|
|||||||
mRegistered = true;
|
mRegistered = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @see DozeSensors.ProxSensor#onSensorChanged(SensorEvent)
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void onSensorChanged(SensorEvent event) {
|
public void onSensorChanged(SensorEvent event) {
|
||||||
if (event.values.length == 0) {
|
if (event.values.length == 0) {
|
||||||
@@ -462,7 +470,14 @@ public class DozeTriggers implements DozeMachine.Part {
|
|||||||
if (DozeMachine.DEBUG) {
|
if (DozeMachine.DEBUG) {
|
||||||
Log.d(TAG, "ProxCheck: Event: value=" + event.values[0] + " max=" + mMaxRange);
|
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);
|
finishWithResult(isNear ? RESULT_NEAR : RESULT_FAR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user