Created
November 26, 2020 14:08
-
-
Save Dil3mm4/f5a9f413fd9fdba69e20762d8c8be151 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
From 740865978d49e4aed56172928b280f5df6c7d16c Mon Sep 17 00:00:00 2001 | |
From: Dil3mm4 <dil3mm4.dev@gmail.com> | |
Date: Thu, 26 Nov 2020 03:48:17 +0000 | |
Subject: [PATCH] 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 | |
diff --git a/packages/SystemUI/src/com/android/systemui/biometrics/FODCircleView.java b/packages/SystemUI/src/com/android/systemui/biometrics/FODCircleView.java | |
index 667ef4885668..5b5dff14016d 100644 | |
--- a/packages/SystemUI/src/com/android/systemui/biometrics/FODCircleView.java | |
+++ b/packages/SystemUI/src/com/android/systemui/biometrics/FODCircleView.java | |
@@ -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,7 @@ import java.util.Timer; | |
import java.util.TimerTask; | |
public class FODCircleView extends ImageView { | |
+ private final int FADE_ANIM_DURATION = 250; | |
private final int mPositionX; | |
private final int mPositionY; | |
private final int mSize; | |
@@ -72,9 +74,12 @@ public class FODCircleView extends ImageView { | |
private int mColor; | |
private int mColorBackground; | |
+ private boolean mFading; | |
private boolean mIsBouncer; | |
- private boolean mIsDreaming; | |
+ private boolean mIsBiometricRunning; | |
private boolean mIsCircleShowing; | |
+ private boolean mIsDreaming; | |
+ private boolean mIsKeyguard; | |
private Handler mHandler; | |
@@ -100,11 +105,34 @@ 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); | |
@@ -113,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; | |
@@ -266,6 +304,7 @@ public class FODCircleView extends ImageView { | |
} | |
public void dispatchPress() { | |
+ if (mFading) return; | |
IFingerprintInscreen daemon = getFingerprintInScreenDaemon(); | |
try { | |
daemon.onPress(); | |
@@ -302,6 +341,7 @@ public class FODCircleView extends ImageView { | |
} | |
public void showCircle() { | |
+ if (mFading) return; | |
mIsCircleShowing = true; | |
setKeepScreenOn(true); | |
@@ -336,14 +376,36 @@ public class FODCircleView extends ImageView { | |
return; | |
} | |
+ if (mUpdateMonitor.getUserCanSkipBouncer(mUpdateMonitor.getCurrentUser())) { | |
+ // Ignore show calls if user can skip bouncer | |
+ return; | |
+ } | |
+ | |
+ if (mIsKeyguard && !mIsBiometricRunning) { | |
+ // Ignore show calls if biometric state is false | |
+ 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() { | |
- setVisibility(View.GONE); | |
+ animate().withStartAction(() -> mFading = true) | |
+ .alpha(0) | |
+ .setDuration(FADE_ANIM_DURATION) | |
+ .withEndAction(() -> { | |
+ setVisibility(View.GONE); | |
+ mFading = false; | |
+ }) | |
+ .start(); | |
hideCircle(); | |
dispatchHide(); | |
} | |
diff --git a/packages/SystemUI/src/com/android/systemui/globalactions/GlobalActionsDialog.java b/packages/SystemUI/src/com/android/systemui/globalactions/GlobalActionsDialog.java | |
index 39a8c1ce31a3..dc4b9daabccf 100644 | |
--- a/packages/SystemUI/src/com/android/systemui/globalactions/GlobalActionsDialog.java | |
+++ b/packages/SystemUI/src/com/android/systemui/globalactions/GlobalActionsDialog.java | |
@@ -2204,7 +2204,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); | |
-- | |
2.20.1 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment