Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 32b61ab2 authored by John Spurlock's avatar John Spurlock Committed by Android (Google) Code Review
Browse files

Merge "Doze: Don't block pickup pulses on a proximity check." into lmp-mr1-dev

parents 1fb69936 621afac8
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -252,7 +252,7 @@
    <integer name="doze_pickup_vibration_threshold">2000</integer>

    <!-- 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? -->
    <integer name="doze_pulse_duration_in">900</integer>
+13 −5
Original line number Diff line number Diff line
@@ -217,22 +217,30 @@ public class DozeService extends DreamService {
            // Here we need a wakelock to stay awake until the pulse is finished.
            mWakeLock.acquire();
            mPulsing = true;
            if (!mDozeParameters.getProxCheckBeforePulse() ||
                    reason == DozeLog.PULSE_REASON_SENSOR_PICKUP
                    && mDozeParameters.getPickupPerformsProxCheck()) {
            if (!mDozeParameters.getProxCheckBeforePulse()) {
                // skip proximity check
                continuePulsing(reason);
                return;
            }
            // perform a proximity check before pulsing
            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() {
                @Override
                public void onProximityResult(int result) {
                    // avoid pulsing in pockets
                    final boolean isNear = result == RESULT_NEAR;
                    final long end = SystemClock.uptimeMillis();
                    DozeLog.traceProximityResult(isNear, end - start, reason);
                    if (nonBlocking) {
                        // we already continued
                        return;
                    }
                    // avoid pulsing in pockets
                    if (isNear) {
                        mPulsing = false;
                        mWakeLock.release();
+7 −4
Original line number Diff line number Diff line
@@ -38,6 +38,7 @@ public class DozeScrimController {

    private final DozeParameters mDozeParameters;
    private final Interpolator mPulseInInterpolator = PhoneStatusBar.ALPHA_OUT;
    private final Interpolator mPulseInInterpolatorPickup;
    private final Interpolator mPulseOutInterpolator = PhoneStatusBar.ALPHA_IN;
    private final Interpolator mDozeAnimationInterpolator;
    private final Handler mHandler = new Handler();
@@ -54,8 +55,8 @@ public class DozeScrimController {
    public DozeScrimController(ScrimController scrimController, Context context) {
        mScrimController = scrimController;
        mDozeParameters = new DozeParameters(context);
        mDozeAnimationInterpolator = AnimationUtils.loadInterpolator(context,
                android.R.interpolator.linear_out_slow_in);
        mDozeAnimationInterpolator = mPulseInInterpolatorPickup =
                AnimationUtils.loadInterpolator(context, android.R.interpolator.linear_out_slow_in);
    }

    public void setDozing(boolean dozing, boolean animate) {
@@ -222,8 +223,10 @@ public class DozeScrimController {
            if (!mDozing) return;
            DozeLog.tracePulseStart(mPulseReason);
            final boolean pickup = mPulseReason == DozeLog.PULSE_REASON_SENSOR_PICKUP;
            startScrimAnimation(true /* inFront */, 0f, mDozeParameters.getPulseInDuration(pickup),
                    mPulseInInterpolator, mDozeParameters.getPulseInDelay(pickup),
            startScrimAnimation(true /* inFront */, 0f,
                    mDozeParameters.getPulseInDuration(pickup),
                    pickup ? mPulseInInterpolatorPickup : mPulseInInterpolator,
                    mDozeParameters.getPulseInDelay(pickup),
                    mPulseInFinished);

            // Signal that the pulse is ready to turn the screen on and draw.