Created
November 29, 2020 15:29
-
-
Save Dil3mm4/8bd699f5d90ce49220e519b0bd0a628a to your computer and use it in GitHub Desktop.
This file contains hidden or 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 66a95e5a5f04e07673f4a6ba5017f2f12f0a435c Mon Sep 17 00:00:00 2001 | |
From: Dil3mm4 <[email protected]> | |
Date: Sat, 28 Nov 2020 05:24:03 +0000 | |
Subject: [PATCH 2/2] FODCircleView: differentiate window type per scenario | |
With this commit we're going to avoid weird FOD states where it dismisses lately/gets stuck occluding the background view (soon to become foreground/in the act of transitioning to foreground). | |
Ex. video before the patch: | |
Ex. video after the patch: | |
Tests executed: | |
- open any third app part that requests biometrics, switch to another app (or go home), observe FOD disappear like it was part of the app where it was called | |
diff --git a/packages/SystemUI/src/com/android/systemui/biometrics/FODCircleView.java b/packages/SystemUI/src/com/android/systemui/biometrics/FODCircleView.java | |
index d370351e3bc4..4e90bad7d2e9 100644 | |
--- a/packages/SystemUI/src/com/android/systemui/biometrics/FODCircleView.java | |
+++ b/packages/SystemUI/src/com/android/systemui/biometrics/FODCircleView.java | |
@@ -225,42 +225,54 @@ public class FODCircleView extends ImageView { | |
mHandler = new Handler(Looper.getMainLooper()); | |
+ mPressedView = new ImageView(context) { | |
+ @Override | |
+ protected void onDraw(Canvas canvas) { | |
+ if (mIsCircleShowing) { | |
+ canvas.drawCircle(mSize / 2, mSize / 2, mSize / 2.0f, mPaintFingerprint); | |
+ } | |
+ super.onDraw(canvas); | |
+ } | |
+ }; | |
+ mPressedView.setImageResource(R.drawable.fod_icon_pressed); | |
+ | |
+ initParams(true); | |
+ | |
+ mLockPatternUtils = new LockPatternUtils(mContext); | |
+ | |
+ mUpdateMonitor = Dependency.get(KeyguardUpdateMonitor.class); | |
+ mUpdateMonitor.registerCallback(mMonitorCallback); | |
+ } | |
+ | |
+ private void initParams(boolean fromConstruct) { | |
+ if (mIsKeyguard && mParams.type == WindowManager.LayoutParams.TYPE_DISPLAY_OVERLAY) return; | |
+ | |
+ if (!fromConstruct) { | |
+ mWindowManager.removeView(this); | |
+ } | |
mParams.height = mSize; | |
mParams.width = mSize; | |
mParams.format = PixelFormat.TRANSLUCENT; | |
mParams.packageName = "android"; | |
- mParams.type = WindowManager.LayoutParams.TYPE_DISPLAY_OVERLAY; | |
+ mParams.type = fromConstruct || mIsKeyguard ? WindowManager.LayoutParams.TYPE_DISPLAY_OVERLAY : WindowManager.LayoutParams.TYPE_INPUT_METHOD_DIALOG; | |
mParams.flags = WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | | |
WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN; | |
mParams.gravity = Gravity.TOP | Gravity.LEFT; | |
mPressedParams.copyFrom(mParams); | |
- mPressedParams.flags |= WindowManager.LayoutParams.FLAG_DIM_BEHIND; | |
+ mPressedParams.type = WindowManager.LayoutParams.TYPE_DISPLAY_OVERLAY; | |
+ mPressedParams.flags |= WindowManager.LayoutParams.FLAG_DIM_BEHIND | WindowManager.LayoutParams.FLAG_WATCH_OUTSIDE_TOUCH; | |
mParams.setTitle("Fingerprint on display"); | |
mPressedParams.setTitle("Fingerprint on display.touched"); | |
- mPressedView = new ImageView(context) { | |
- @Override | |
- protected void onDraw(Canvas canvas) { | |
- if (mIsCircleShowing) { | |
- canvas.drawCircle(mSize / 2, mSize / 2, mSize / 2.0f, mPaintFingerprint); | |
- } | |
- super.onDraw(canvas); | |
- } | |
- }; | |
- mPressedView.setImageResource(R.drawable.fod_icon_pressed); | |
- | |
mWindowManager.addView(this, mParams); | |
updatePosition(); | |
- hide(); | |
- | |
- mLockPatternUtils = new LockPatternUtils(mContext); | |
- | |
- mUpdateMonitor = Dependency.get(KeyguardUpdateMonitor.class); | |
- mUpdateMonitor.registerCallback(mMonitorCallback); | |
+ if (fromConstruct) { | |
+ hide(); | |
+ } | |
} | |
@Override | |
@@ -366,6 +378,7 @@ public class FODCircleView extends ImageView { | |
public void hideCircle() { | |
mIsCircleShowing = false; | |
+ if (!mIsKeyguard) setVisibility(View.GONE); | |
setImageResource(R.drawable.fod_icon_default); | |
invalidate(); | |
@@ -395,7 +408,7 @@ public class FODCircleView extends ImageView { | |
return; | |
} | |
- updatePosition(); | |
+ initParams(false); | |
setVisibility(View.VISIBLE); | |
animate().withStartAction(() -> mFading = true) | |
-- | |
2.20.1 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment