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

Commit fe444b48 authored by Steven Ross's avatar Steven Ross
Browse files

Always showing FaceUnlock view before bind fixes 6330358

Sets the view to visible directly on the UI thread when feasible
this includes all cases where FaceUnlock is bound.
The delay in processing a message was causing the bug.
This additionally replaces the call in the keyguardview show
with one when the facelockareaview is initialized.

Change-Id: I8511f175d68023372e11d6e76fa1c44df6ac8a3d
parent cf6960ed
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -29,6 +29,7 @@ interface BiometricSensorUnlock {
    // Show the interface, but don't start the unlock procedure.  The interface should disappear
    // after the specified timeout.  If the timeout is 0, the interface shows until another event,
    // such as calling hide(), causes it to disappear.
    // Called on the UI Thread
    public void show(long timeoutMilliseconds);

    // Hide the interface, if any, exposing the lockscreen.
@@ -39,6 +40,7 @@ interface BiometricSensorUnlock {

    // Start the unlock procedure.  Returns ‘false’ if it can’t be started or if the backup should
    // be used.
    // Called on the UI thread.
    public boolean start(boolean suppressBiometricUnlock);

    // Provide a view to work within.
+22 −13
Original line number Diff line number Diff line
@@ -88,7 +88,9 @@ public class FaceUnlock implements BiometricSensorUnlock, Handler.Callback {
    }

    // Shows the FaceLock area for a period of time
    // Called on the UI thread
    public void show(long timeoutMillis) {
        removeAreaDisplayMessages();
        showArea();
        if (timeoutMillis > 0)
            mHandler.sendEmptyMessageDelayed(MSG_HIDE_AREA_VIEW, timeoutMillis);
@@ -134,6 +136,7 @@ public class FaceUnlock implements BiometricSensorUnlock, Handler.Callback {
    /**
     * When screen is turned on and focused, need to bind to FaceLock service if we are using
     * FaceLock, but only if we're not dealing with a call
     * Called on the UI thread
     */
    public boolean start(boolean suppressBiometricUnlock) {
        final boolean tooManyFaceUnlockTries = mUpdateMonitor.getMaxFaceUnlockAttemptsReached();
@@ -146,12 +149,13 @@ public class FaceUnlock implements BiometricSensorUnlock, Handler.Callback {
                && !suppressBiometricUnlock
                && !tooManyFaceUnlockTries
                && !backupIsTimedOut) {
            bind();

            // Show FaceLock area, but only for a little bit so lockpattern will become visible if
            // FaceLock fails to start or crashes
            // This must show before bind to guarantee that Face Unlock has a place to display
            show(VIEW_AREA_SERVICE_TIMEOUT);

            bind();

            // When switching between portrait and landscape view while FaceLock is running, the
            // screen will eventually go dark unless we poke the wakelock when FaceLock is
            // restarted
@@ -170,6 +174,8 @@ public class FaceUnlock implements BiometricSensorUnlock, Handler.Callback {
            mAreaView = topView.findViewById(R.id.faceLockAreaView);
            if (mAreaView == null) {
                Log.e(TAG, "Layout does not have areaView and FaceLock is enabled");
            } else {
                show(0);
            }
        } else {
            mAreaView = null; // Set to null if not using FaceLock
@@ -192,6 +198,14 @@ public class FaceUnlock implements BiometricSensorUnlock, Handler.Callback {
        return DevicePolicyManager.PASSWORD_QUALITY_BIOMETRIC_WEAK;
    }

    // Shows the FaceLock area
    // Called on the UI thread
    private void showArea() {
        if (mAreaView != null) {
            mAreaView.setVisibility(View.VISIBLE);
        }
    }

    // Handles covering or exposing FaceLock area on the client side when FaceLock starts or stops
    // This needs to be done in a handler because the call could be coming from a callback from the
    // FaceLock service that is in a thread that can't modify the UI
@@ -199,9 +213,7 @@ public class FaceUnlock implements BiometricSensorUnlock, Handler.Callback {
    public boolean handleMessage(Message msg) {
        switch (msg.what) {
        case MSG_SHOW_AREA_VIEW:
            if (mAreaView != null) {
                mAreaView.setVisibility(View.VISIBLE);
            }
            showArea();
            break;
        case MSG_HIDE_AREA_VIEW:
            if (mAreaView != null) {
@@ -221,13 +233,6 @@ public class FaceUnlock implements BiometricSensorUnlock, Handler.Callback {
        mHandler.removeMessages(MSG_HIDE_AREA_VIEW);
    }

    // Shows the FaceLock area immediately
    private void showArea() {
        // Remove messages to prevent a delayed hide message from undo-ing the show
        removeAreaDisplayMessages();
        mHandler.sendEmptyMessage(MSG_SHOW_AREA_VIEW);
    }

    // Binds to FaceLock service.  This call does not tell it to start, but it causes the service
    // to call the onServiceConnected callback, which then starts FaceLock.
    private void bind() {
@@ -329,7 +334,11 @@ public class FaceUnlock implements BiometricSensorUnlock, Handler.Callback {
        @Override
        public void unlock() {
            if (DEBUG) Log.d(TAG, "FaceLock unlock()");
            showArea(); // Keep fallback covered

            // Keep fallback covered
            removeAreaDisplayMessages();
            mHandler.sendEmptyMessage(MSG_SHOW_AREA_VIEW);

            stop();

            mKeyguardScreenCallback.keyguardDone(true);
+1 −7
Original line number Diff line number Diff line
@@ -613,13 +613,7 @@ public class LockPatternKeyguardView extends KeyguardViewBase {
            ((KeyguardScreen) mUnlockScreen).onResume();
        }

        if (mBiometricUnlock.installedAndSelected() && !mSupressBiometricUnlock) {
            // Note that show() gets called before the screen turns off to set it up for next time
            // it is turned on.  We don't want to set a timeout on the biometric unlock here because
            // it may be gone by the time the screen is turned on again.  We set the timeout when
            // the screen turns on instead.
            mBiometricUnlock.show(0);
        } else {
        if (!mBiometricUnlock.installedAndSelected() || mSupressBiometricUnlock) {
            mBiometricUnlock.hide();
        }
    }