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

Commit caa6cb3a authored by Jorim Jaggi's avatar Jorim Jaggi Committed by Android Git Automerger
Browse files

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

* commit '394686ef':
  Fix race condition for doze mode and wake-and-unlocking
parents ca3c865d 394686ef
Loading
Loading
Loading
Loading
+29 −0
Original line number Diff line number Diff line
@@ -409,6 +409,10 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener {
    }

    private void handleFingerprintAuthFailed() {
        if (mFpWakeMode == FP_WAKE_DIRECT_UNLOCK) {
            notifyOnFingerprintWakeAndUnlockingFinished();
        }
        mFpWakeMode = FP_WAKE_NONE;
        releaseFingerprintWakeLock();
        handleFingerprintHelp(-1, mContext.getString(R.string.fingerprint_not_recognized));
    }
@@ -428,6 +432,9 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener {
            }
            mHandler.postDelayed(mReleaseFingerprintWakeLockRunnable,
                    FINGERPRINT_WAKELOCK_TIMEOUT_MS);
            if (mFpWakeMode == FP_WAKE_DIRECT_UNLOCK) {
                notifyOnFingerprintWakeAndUnlockingStarted();
            }
        } else if (!mDeviceInteractive) {
            mFpWakeMode = FP_WAKE_TO_BOUNCER;
        } 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() {
        @Override
        public void run() {
@@ -891,6 +916,10 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener {
                cb.onScreenTurnedOn();
            }
        }
        if (mFpWakeMode == FP_WAKE_DIRECT_UNLOCK) {
            notifyOnFingerprintWakeAndUnlockingFinished();
        }
        mFpWakeMode = FP_WAKE_NONE;
    }

    private void handleScreenTurnedOff() {
+11 −0
Original line number Diff line number Diff line
@@ -193,6 +193,17 @@ public class KeyguardUpdateMonitorCallback {
     */
    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")
     * @param msgId
+1 −0
Original line number Diff line number Diff line
@@ -29,6 +29,7 @@ public interface DozeHost {
    void stopDozing();
    boolean isPowerSaveActive();
    boolean isNotificationLightOn();
    boolean isPulsingBlocked();

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

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

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

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