Merge "Doze: Don't block pickup pulses on a proximity check." into lmp-mr1-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
32b61ab28f
@@ -252,7 +252,7 @@
|
|||||||
<integer name="doze_pickup_vibration_threshold">2000</integer>
|
<integer name="doze_pickup_vibration_threshold">2000</integer>
|
||||||
|
|
||||||
<!-- Doze: can we assume the pickup sensor includes a proximity check? -->
|
<!-- Doze: can we assume the pickup sensor includes a proximity check? -->
|
||||||
<bool name="doze_pickup_performs_proximity_check">false</bool>
|
<bool name="doze_pickup_performs_proximity_check">true</bool>
|
||||||
|
|
||||||
<!-- Doze: pulse parameter - how long does it take to fade in? -->
|
<!-- Doze: pulse parameter - how long does it take to fade in? -->
|
||||||
<integer name="doze_pulse_duration_in">900</integer>
|
<integer name="doze_pulse_duration_in">900</integer>
|
||||||
|
|||||||
@@ -217,22 +217,30 @@ public class DozeService extends DreamService {
|
|||||||
// Here we need a wakelock to stay awake until the pulse is finished.
|
// Here we need a wakelock to stay awake until the pulse is finished.
|
||||||
mWakeLock.acquire();
|
mWakeLock.acquire();
|
||||||
mPulsing = true;
|
mPulsing = true;
|
||||||
if (!mDozeParameters.getProxCheckBeforePulse() ||
|
if (!mDozeParameters.getProxCheckBeforePulse()) {
|
||||||
reason == DozeLog.PULSE_REASON_SENSOR_PICKUP
|
|
||||||
&& mDozeParameters.getPickupPerformsProxCheck()) {
|
|
||||||
// skip proximity check
|
// skip proximity check
|
||||||
continuePulsing(reason);
|
continuePulsing(reason);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// perform a proximity check before pulsing
|
|
||||||
final long start = SystemClock.uptimeMillis();
|
final long start = SystemClock.uptimeMillis();
|
||||||
|
final boolean nonBlocking = reason == DozeLog.PULSE_REASON_SENSOR_PICKUP
|
||||||
|
&& mDozeParameters.getPickupPerformsProxCheck();
|
||||||
|
if (nonBlocking) {
|
||||||
|
// proximity check is only done to capture statistics, continue pulsing
|
||||||
|
continuePulsing(reason);
|
||||||
|
}
|
||||||
|
// perform a proximity check
|
||||||
new ProximityCheck() {
|
new ProximityCheck() {
|
||||||
@Override
|
@Override
|
||||||
public void onProximityResult(int result) {
|
public void onProximityResult(int result) {
|
||||||
// avoid pulsing in pockets
|
|
||||||
final boolean isNear = result == RESULT_NEAR;
|
final boolean isNear = result == RESULT_NEAR;
|
||||||
final long end = SystemClock.uptimeMillis();
|
final long end = SystemClock.uptimeMillis();
|
||||||
DozeLog.traceProximityResult(isNear, end - start, reason);
|
DozeLog.traceProximityResult(isNear, end - start, reason);
|
||||||
|
if (nonBlocking) {
|
||||||
|
// we already continued
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// avoid pulsing in pockets
|
||||||
if (isNear) {
|
if (isNear) {
|
||||||
mPulsing = false;
|
mPulsing = false;
|
||||||
mWakeLock.release();
|
mWakeLock.release();
|
||||||
|
|||||||
@@ -38,6 +38,7 @@ public class DozeScrimController {
|
|||||||
|
|
||||||
private final DozeParameters mDozeParameters;
|
private final DozeParameters mDozeParameters;
|
||||||
private final Interpolator mPulseInInterpolator = PhoneStatusBar.ALPHA_OUT;
|
private final Interpolator mPulseInInterpolator = PhoneStatusBar.ALPHA_OUT;
|
||||||
|
private final Interpolator mPulseInInterpolatorPickup;
|
||||||
private final Interpolator mPulseOutInterpolator = PhoneStatusBar.ALPHA_IN;
|
private final Interpolator mPulseOutInterpolator = PhoneStatusBar.ALPHA_IN;
|
||||||
private final Interpolator mDozeAnimationInterpolator;
|
private final Interpolator mDozeAnimationInterpolator;
|
||||||
private final Handler mHandler = new Handler();
|
private final Handler mHandler = new Handler();
|
||||||
@@ -54,8 +55,8 @@ public class DozeScrimController {
|
|||||||
public DozeScrimController(ScrimController scrimController, Context context) {
|
public DozeScrimController(ScrimController scrimController, Context context) {
|
||||||
mScrimController = scrimController;
|
mScrimController = scrimController;
|
||||||
mDozeParameters = new DozeParameters(context);
|
mDozeParameters = new DozeParameters(context);
|
||||||
mDozeAnimationInterpolator = AnimationUtils.loadInterpolator(context,
|
mDozeAnimationInterpolator = mPulseInInterpolatorPickup =
|
||||||
android.R.interpolator.linear_out_slow_in);
|
AnimationUtils.loadInterpolator(context, android.R.interpolator.linear_out_slow_in);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDozing(boolean dozing, boolean animate) {
|
public void setDozing(boolean dozing, boolean animate) {
|
||||||
@@ -222,8 +223,10 @@ public class DozeScrimController {
|
|||||||
if (!mDozing) return;
|
if (!mDozing) return;
|
||||||
DozeLog.tracePulseStart(mPulseReason);
|
DozeLog.tracePulseStart(mPulseReason);
|
||||||
final boolean pickup = mPulseReason == DozeLog.PULSE_REASON_SENSOR_PICKUP;
|
final boolean pickup = mPulseReason == DozeLog.PULSE_REASON_SENSOR_PICKUP;
|
||||||
startScrimAnimation(true /* inFront */, 0f, mDozeParameters.getPulseInDuration(pickup),
|
startScrimAnimation(true /* inFront */, 0f,
|
||||||
mPulseInInterpolator, mDozeParameters.getPulseInDelay(pickup),
|
mDozeParameters.getPulseInDuration(pickup),
|
||||||
|
pickup ? mPulseInInterpolatorPickup : mPulseInInterpolator,
|
||||||
|
mDozeParameters.getPulseInDelay(pickup),
|
||||||
mPulseInFinished);
|
mPulseInFinished);
|
||||||
|
|
||||||
// Signal that the pulse is ready to turn the screen on and draw.
|
// Signal that the pulse is ready to turn the screen on and draw.
|
||||||
|
|||||||
Reference in New Issue
Block a user