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

Commit 46958986 authored by Dil3mm4's avatar Dil3mm4 Committed by LuK1337
Browse files

FODCircleView: various improvements.

Added fade-out to FOD view, before going to View.GONE
Tests executed:
    - Ensured animation executes correctly
    - Ensured interaction with FOD (or any other biometric method) wouldn't compromise animation execution or with FOD functionality itself
    - Ensured that alpha values triggered with the animation, are correct over different lockscreen states

Handled more visibility cases
Tests executed:
    - Added a Bluetooth device as Trusted Device via Smart Lock, ensured FOD wasn't visible
    - Used other biometric methods to unlock the device, ensured FOD wasn't visible
    - Enabled On-body detection, ensured FOD wasn't visible
    - Enabled Trusted places, ensured FOD wasn't visible
    - Triggered biometric failure with too many unrecognized attempts, ensured FOD wasn't visible while transitioning back and forth from AOD.
    - Triggered floating biometric dialog and ensured its functionality

Change GlobalActionsDialog window type to TYPE_DISPLAY_OVERLAY (same as FOD view), so that whoever gets called last, will go on-top
Tests executed:
    - On a secured lockscreen, triggered GlobalActionsDialog via power menu, ensured FOD was in foreground instead of on-top

LuK1337:
Solved a visibility edge case
Tests executed:
    - On a secured lockscreen, with "double tap power button to open camera gesture" disabled, double tap the power button,
      ensure FOD correct visibility

Change-Id: I8318ff0bd528af40c7b9d9ec028b88eb1d5e2674
parent 99e5a73c
Loading
Loading
Loading
Loading
+74 −3
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@ import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.PixelFormat;
import android.graphics.Point;
import android.hardware.biometrics.BiometricSourceType;
import android.os.Handler;
import android.os.Looper;
import android.os.RemoteException;
@@ -52,6 +53,8 @@ import java.util.Timer;
import java.util.TimerTask;

public class FODCircleView extends ImageView {
    private static final int FADE_ANIM_DURATION = 250;

    private final int mPositionX;
    private final int mPositionY;
    private final int mSize;
@@ -69,9 +72,12 @@ public class FODCircleView extends ImageView {
    private int mDreamingOffsetX;
    private int mDreamingOffsetY;

    private boolean mFading;
    private boolean mIsBouncer;
    private boolean mIsDreaming;
    private boolean mIsBiometricRunning;
    private boolean mIsCircleShowing;
    private boolean mIsDreaming;
    private boolean mIsKeyguard;

    private Handler mHandler;

@@ -97,11 +103,36 @@ public class FODCircleView extends ImageView {
    private KeyguardUpdateMonitor mUpdateMonitor;

    private KeyguardUpdateMonitorCallback mMonitorCallback = new KeyguardUpdateMonitorCallback() {
        @Override
        public void onBiometricAuthenticated(int userId, BiometricSourceType biometricSourceType,
                boolean isStrongBiometric) {
            // We assume that if biometricSourceType matches Fingerprint it will be
            // handled here, so we hide only when other biometric types authenticate
            if (biometricSourceType != BiometricSourceType.FINGERPRINT) {
                hide();
            }
        }

        @Override
        public void onBiometricRunningStateChanged(boolean running,
                BiometricSourceType biometricSourceType) {
            if (biometricSourceType == BiometricSourceType.FINGERPRINT) {
                mIsBiometricRunning = running;
            }
        }

        @Override
        public void onDreamingStateChanged(boolean dreaming) {
            mIsDreaming = dreaming;
            updateAlpha();

            if (mIsKeyguard && mUpdateMonitor.isFingerprintDetectionRunning()) {
                show();
                updateAlpha();
            } else {
                hide();
            }

            if (dreaming) {
                mBurnInProtectionTimer = new Timer();
                mBurnInProtectionTimer.schedule(new BurnInProtectionTask(), 0, 60 * 1000);
@@ -110,6 +141,16 @@ public class FODCircleView extends ImageView {
            }
        }

        @Override
        public void onKeyguardVisibilityChanged(boolean showing) {
            mIsKeyguard = showing;
            if (!showing) {
                hide();
            } else {
                updateAlpha();
            }
        }

        @Override
        public void onKeyguardBouncerChanged(boolean isBouncer) {
            mIsBouncer = isBouncer;
@@ -129,6 +170,13 @@ public class FODCircleView extends ImageView {
            hide();
        }

        @Override
        public void onStartedWakingUp() {
            if (mUpdateMonitor.isFingerprintDetectionRunning()) {
                show();
            }
        }

        @Override
        public void onScreenTurnedOn() {
            if (mUpdateMonitor.isFingerprintDetectionRunning()) {
@@ -261,6 +309,7 @@ public class FODCircleView extends ImageView {
    }

    public void dispatchPress() {
        if (mFading) return;
        IFingerprintInscreen daemon = getFingerprintInScreenDaemon();
        try {
            daemon.onPress();
@@ -297,6 +346,7 @@ public class FODCircleView extends ImageView {
    }

    public void showCircle() {
        if (mFading) return;
        mIsCircleShowing = true;

        setKeepScreenOn(true);
@@ -331,14 +381,35 @@ public class FODCircleView extends ImageView {
            return;
        }

        if (mUpdateMonitor.getUserCanSkipBouncer(mUpdateMonitor.getCurrentUser())) {
            // Ignore show calls if user can skip bouncer
            return;
        }

        if (mIsKeyguard && !mIsBiometricRunning) {
            return;
        }

        updatePosition();

        dispatchShow();
        setVisibility(View.VISIBLE);
        animate().withStartAction(() -> mFading = true)
                .alpha(mIsDreaming ? 0.5f : 1.0f)
                .setDuration(FADE_ANIM_DURATION)
                .withEndAction(() -> mFading = false)
                .start();
        dispatchShow();
    }

    public void hide() {
        animate().withStartAction(() -> mFading = true)
                .alpha(0)
                .setDuration(FADE_ANIM_DURATION)
                .withEndAction(() -> {
                    setVisibility(View.GONE);
                    mFading = false;
                })
                .start();
        hideCircle();
        dispatchHide();
    }
+1 −1
Original line number Diff line number Diff line
@@ -2404,7 +2404,7 @@ public class GlobalActionsDialog implements DialogInterface.OnDismissListener,
                            | WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED
                            | WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH
                            | WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED);
            window.setType(WindowManager.LayoutParams.TYPE_VOLUME_OVERLAY);
            window.setType(WindowManager.LayoutParams.TYPE_DISPLAY_OVERLAY);
            window.getAttributes().setFitInsetsTypes(0 /* types */);
            setTitle(R.string.global_actions);