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

Commit 394686ef authored by Jorim Jaggi's avatar Jorim Jaggi Committed by Android (Google) Code Review
Browse files

Merge "Fix race condition for doze mode and wake-and-unlocking" into mnc-dr-dev

parents 892768fb 007f0e8f
Loading
Loading
Loading
Loading
+29 −0
Original line number Original line Diff line number Diff line
@@ -409,6 +409,10 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener {
    }
    }


    private void handleFingerprintAuthFailed() {
    private void handleFingerprintAuthFailed() {
        if (mFpWakeMode == FP_WAKE_DIRECT_UNLOCK) {
            notifyOnFingerprintWakeAndUnlockingFinished();
        }
        mFpWakeMode = FP_WAKE_NONE;
        releaseFingerprintWakeLock();
        releaseFingerprintWakeLock();
        handleFingerprintHelp(-1, mContext.getString(R.string.fingerprint_not_recognized));
        handleFingerprintHelp(-1, mContext.getString(R.string.fingerprint_not_recognized));
    }
    }
@@ -428,6 +432,9 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener {
            }
            }
            mHandler.postDelayed(mReleaseFingerprintWakeLockRunnable,
            mHandler.postDelayed(mReleaseFingerprintWakeLockRunnable,
                    FINGERPRINT_WAKELOCK_TIMEOUT_MS);
                    FINGERPRINT_WAKELOCK_TIMEOUT_MS);
            if (mFpWakeMode == FP_WAKE_DIRECT_UNLOCK) {
                notifyOnFingerprintWakeAndUnlockingStarted();
            }
        } else if (!mDeviceInteractive) {
        } else if (!mDeviceInteractive) {
            mFpWakeMode = FP_WAKE_TO_BOUNCER;
            mFpWakeMode = FP_WAKE_TO_BOUNCER;
        } else {
        } else {
@@ -435,6 +442,24 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener {
        }
        }
    }
    }


    private void notifyOnFingerprintWakeAndUnlockingStarted() {
        for (int i = 0; i < mCallbacks.size(); i++) {
            KeyguardUpdateMonitorCallback cb = mCallbacks.get(i).get();
            if (cb != null) {
                cb.onFingerprintWakeAndUnlockingStarted();
            }
        }
    }

    private void notifyOnFingerprintWakeAndUnlockingFinished() {
        for (int i = 0; i < mCallbacks.size(); i++) {
            KeyguardUpdateMonitorCallback cb = mCallbacks.get(i).get();
            if (cb != null) {
                cb.onFingerprintWakeAndUnlockingFinished();
            }
        }
    }

    private final Runnable mReleaseFingerprintWakeLockRunnable = new Runnable() {
    private final Runnable mReleaseFingerprintWakeLockRunnable = new Runnable() {
        @Override
        @Override
        public void run() {
        public void run() {
@@ -891,6 +916,10 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener {
                cb.onScreenTurnedOn();
                cb.onScreenTurnedOn();
            }
            }
        }
        }
        if (mFpWakeMode == FP_WAKE_DIRECT_UNLOCK) {
            notifyOnFingerprintWakeAndUnlockingFinished();
        }
        mFpWakeMode = FP_WAKE_NONE;
    }
    }


    private void handleScreenTurnedOff() {
    private void handleScreenTurnedOff() {
+11 −0
Original line number Original line Diff line number Diff line
@@ -193,6 +193,17 @@ public class KeyguardUpdateMonitorCallback {
     */
     */
    public void onFingerprintAuthenticated(int userId, boolean wakeAndUnlocking) { }
    public void onFingerprintAuthenticated(int userId, boolean wakeAndUnlocking) { }


    /**
     * Called when we might be starting a wake-and-unlock sequence.
     */
    public void onFingerprintWakeAndUnlockingStarted() { }

    /**
     * Called when we're done with the wake-and-unlock sequence. This can either happen when we
     * figure out that the fingerprint didn't match, or when the phone is fully unlocked.
     */
    public void onFingerprintWakeAndUnlockingFinished() { }

    /**
    /**
     * Called when fingerprint provides help string (e.g. "Try again")
     * Called when fingerprint provides help string (e.g. "Try again")
     * @param msgId
     * @param msgId
+1 −0
Original line number Original line Diff line number Diff line
@@ -29,6 +29,7 @@ public interface DozeHost {
    void stopDozing();
    void stopDozing();
    boolean isPowerSaveActive();
    boolean isPowerSaveActive();
    boolean isNotificationLightOn();
    boolean isNotificationLightOn();
    boolean isPulsingBlocked();


    public interface Callback {
    public interface Callback {
        void onNewNotifications();
        void onNewNotifications();
+3 −0
Original line number Original line Diff line number Diff line
@@ -255,6 +255,9 @@ public class DozeService extends DreamService {
    }
    }


    private void continuePulsing(int reason) {
    private void continuePulsing(int reason) {
        if (mHost.isPulsingBlocked()) {
            return;
        }
        mHost.pulseWhileDozing(new DozeHost.PulseCallback() {
        mHost.pulseWhileDozing(new DozeHost.PulseCallback() {
            @Override
            @Override
            public void onPulseStarted() {
            public void onPulseStarted() {
+11 −0
Original line number Original line Diff line number Diff line
@@ -100,6 +100,17 @@ public class DozeScrimController {
        mHandler.post(mPulseIn);
        mHandler.post(mPulseIn);
    }
    }


    /**
     * Aborts pulsing immediately.
     */
    public void abortPulsing() {
        mHandler.removeCallbacks(mPulseIn);
        abortAnimations();
        mScrimController.setDozeBehindAlpha(1f);
        mScrimController.setDozeInFrontAlpha(1f);
        mPulseCallback = null;
    }

    public void onScreenTurnedOn() {
    public void onScreenTurnedOn() {
        if (isPulsing()) {
        if (isPulsing()) {
            final boolean pickup = mPulseReason == DozeLog.PULSE_REASON_SENSOR_PICKUP;
            final boolean pickup = mPulseReason == DozeLog.PULSE_REASON_SENSOR_PICKUP;
Loading