From a883fb5f8fbfee25c8773c4858161b7aa9722a8e Mon Sep 17 00:00:00 2001 From: Kevin Chyn Date: Tue, 18 Sep 2018 18:23:22 -0700 Subject: [PATCH 1/3] 1/n: Rename FingerprintDialogView to BiometricDialogView This is to preserve git history, see other changes in the topic :) Bug: 111461540 Test: BiometricPromptDemo works Change-Id: I5c7b45024743bf5c5ccf0ccb7e30b97ab24ca2bc --- .../systemui/biometrics/BiometricDialogImpl.java | 6 +++--- ...printDialogView.java => BiometricDialogView.java} | 12 ++++++------ 2 files changed, 9 insertions(+), 9 deletions(-) rename packages/SystemUI/src/com/android/systemui/biometrics/{FingerprintDialogView.java => BiometricDialogView.java} (97%) diff --git a/packages/SystemUI/src/com/android/systemui/biometrics/BiometricDialogImpl.java b/packages/SystemUI/src/com/android/systemui/biometrics/BiometricDialogImpl.java index 8fe577a4cec05..7359daa9dc6db 100644 --- a/packages/SystemUI/src/com/android/systemui/biometrics/BiometricDialogImpl.java +++ b/packages/SystemUI/src/com/android/systemui/biometrics/BiometricDialogImpl.java @@ -33,7 +33,7 @@ import com.android.systemui.statusbar.CommandQueue; /** * Receives messages sent from AuthenticationClient and shows the appropriate biometric UI (e.g. - * FingerprintDialogView). + * BiometricDialogView). */ public class BiometricDialogImpl extends SystemUI implements CommandQueue.Callbacks { private static final String TAG = "BiometricDialogImpl"; @@ -48,7 +48,7 @@ public class BiometricDialogImpl extends SystemUI implements CommandQueue.Callba private static final int MSG_USER_CANCELED = 7; private static final int MSG_BUTTON_POSITIVE = 8; - private FingerprintDialogView mDialogView; + private BiometricDialogView mDialogView; private WindowManager mWindowManager; private IBiometricPromptReceiver mReceiver; private boolean mDialogShowing; @@ -116,7 +116,7 @@ public class BiometricDialogImpl extends SystemUI implements CommandQueue.Callba } getComponent(CommandQueue.class).addCallbacks(this); mWindowManager = (WindowManager) mContext.getSystemService(Context.WINDOW_SERVICE); - mDialogView = new FingerprintDialogView(mContext, mCallback); + mDialogView = new BiometricDialogView(mContext, mCallback); } @Override diff --git a/packages/SystemUI/src/com/android/systemui/biometrics/FingerprintDialogView.java b/packages/SystemUI/src/com/android/systemui/biometrics/BiometricDialogView.java similarity index 97% rename from packages/SystemUI/src/com/android/systemui/biometrics/FingerprintDialogView.java rename to packages/SystemUI/src/com/android/systemui/biometrics/BiometricDialogView.java index 68c2c42dd9614..9ebd54b670ebb 100644 --- a/packages/SystemUI/src/com/android/systemui/biometrics/FingerprintDialogView.java +++ b/packages/SystemUI/src/com/android/systemui/biometrics/BiometricDialogView.java @@ -50,9 +50,9 @@ import com.android.systemui.R; * Application Icon, Title, Subtitle, Description, Fingerprint Icon, Error/Help message area, * and positive/negative buttons. */ -public class FingerprintDialogView extends LinearLayout { +public class BiometricDialogView extends LinearLayout { - private static final String TAG = "FingerprintDialogView"; + private static final String TAG = "BiometricDialogView"; private static final int ANIMATION_DURATION_SHOW = 250; // ms private static final int ANIMATION_DURATION_AWAY = 350; // ms @@ -114,7 +114,7 @@ public class FingerprintDialogView extends LinearLayout { } }; - public FingerprintDialogView(Context context, DialogViewCallback callback) { + public BiometricDialogView(Context context, DialogViewCallback callback) { super(context); mCallback = callback; mLinearOutSlowIn = Interpolators.LINEAR_OUT_SLOW_IN; @@ -257,7 +257,7 @@ public class FingerprintDialogView extends LinearLayout { final Runnable endActionRunnable = new Runnable() { @Override public void run() { - mWindowManager.removeView(FingerprintDialogView.this); + mWindowManager.removeView(BiometricDialogView.this); mAnimatingAway = false; } }; @@ -290,7 +290,7 @@ public class FingerprintDialogView extends LinearLayout { public void forceRemove() { mLayout.animate().cancel(); mDialog.animate().cancel(); - mWindowManager.removeView(FingerprintDialogView.this); + mWindowManager.removeView(BiometricDialogView.this); mAnimatingAway = false; mWasForceRemoved = true; } @@ -393,7 +393,7 @@ public class FingerprintDialogView extends LinearLayout { WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED, PixelFormat.TRANSLUCENT); lp.privateFlags |= WindowManager.LayoutParams.PRIVATE_FLAG_SHOW_FOR_ALL_USERS; - lp.setTitle("FingerprintDialogView"); + lp.setTitle("BiometricDialogView"); lp.token = mWindowToken; return lp; } From 0be1f33757e700fd0098bd73832eb604a7bb6c82 Mon Sep 17 00:00:00 2001 From: Kevin Chyn Date: Tue, 18 Sep 2018 18:15:16 -0700 Subject: [PATCH 2/3] 2/n: Refactor common code from FingerprintDialogView Bug: 111461540 Test: BiometricPromptDemo works Change-Id: I7077b062f1da0e084a38d5d53248123a82456a48 --- .../res/drawable/fingerprint_dialog_bg.xml | 6 +- .../fingerprint_dialog_error_to_fp.xml | 16 +-- .../fingerprint_dialog_fp_to_error.xml | 26 ++--- .../res/layout/fingerprint_dialog.xml | 14 +-- packages/SystemUI/res/values/colors.xml | 14 +-- packages/SystemUI/res/values/dimens.xml | 6 +- .../biometrics/BiometricDialogImpl.java | 2 +- .../biometrics/BiometricDialogView.java | 100 ++++------------ .../biometrics/FingerprintDialogView.java | 108 ++++++++++++++++++ 9 files changed, 175 insertions(+), 117 deletions(-) create mode 100644 packages/SystemUI/src/com/android/systemui/biometrics/FingerprintDialogView.java diff --git a/packages/SystemUI/res/drawable/fingerprint_dialog_bg.xml b/packages/SystemUI/res/drawable/fingerprint_dialog_bg.xml index 221f1701187d6..335448d823739 100644 --- a/packages/SystemUI/res/drawable/fingerprint_dialog_bg.xml +++ b/packages/SystemUI/res/drawable/fingerprint_dialog_bg.xml @@ -17,10 +17,10 @@ --> - + \ No newline at end of file diff --git a/packages/SystemUI/res/drawable/fingerprint_dialog_error_to_fp.xml b/packages/SystemUI/res/drawable/fingerprint_dialog_error_to_fp.xml index 83c1949b681ca..05fd467b749e4 100644 --- a/packages/SystemUI/res/drawable/fingerprint_dialog_error_to_fp.xml +++ b/packages/SystemUI/res/drawable/fingerprint_dialog_error_to_fp.xml @@ -36,7 +36,7 @@ android:name="_R_G_L_2_G_D_0_P_0" android:pathData=" M-25.36 -24.41 C-25.93,-24.31 -26.49,-24.27 -26.81,-24.27 C-28.11,-24.27 -29.35,-24.62 -30.43,-25.4 C-32.11,-26.6 -33.2,-28.57 -33.2,-30.79 " android:strokeAlpha="1" - android:strokeColor="@color/fingerprint_dialog_fingerprint_color" + android:strokeColor="@color/biometric_dialog_biometric_color" android:strokeLineCap="round" android:strokeLineJoin="round" android:strokeWidth="1.45" @@ -47,7 +47,7 @@ android:name="_R_G_L_2_G_D_1_P_0" android:pathData=" M-36.14 -21.78 C-37.15,-22.98 -37.72,-23.7 -38.51,-25.29 C-39.33,-26.94 -39.82,-28.78 -39.82,-30.77 C-39.82,-34.43 -36.85,-37.4 -33.19,-37.4 C-29.52,-37.4 -26.55,-34.43 -26.55,-30.77 " android:strokeAlpha="1" - android:strokeColor="@color/fingerprint_dialog_fingerprint_color" + android:strokeColor="@color/biometric_dialog_biometric_color" android:strokeLineCap="round" android:strokeLineJoin="round" android:strokeWidth="1.45" @@ -58,7 +58,7 @@ android:name="_R_G_L_2_G_D_2_P_0" android:pathData=" M-42.19 -25.68 C-42.95,-27.82 -43.09,-29.54 -43.09,-30.8 C-43.09,-32.27 -42.84,-33.65 -42.27,-34.9 C-40.71,-38.35 -37.24,-40.75 -33.2,-40.75 C-27.71,-40.75 -23.26,-36.3 -23.26,-30.8 C-23.26,-28.97 -24.74,-27.49 -26.57,-27.49 C-28.4,-27.49 -29.89,-28.97 -29.89,-30.8 C-29.89,-32.64 -31.37,-34.12 -33.2,-34.12 C-35.04,-34.12 -36.52,-32.64 -36.52,-30.8 C-36.52,-28.23 -35.53,-25.92 -33.92,-24.22 C-32.69,-22.93 -31.48,-22.12 -29.44,-21.53 " android:strokeAlpha="1" - android:strokeColor="@color/fingerprint_dialog_fingerprint_color" + android:strokeColor="@color/biometric_dialog_biometric_color" android:strokeLineCap="round" android:strokeLineJoin="round" android:strokeWidth="1.45" @@ -69,7 +69,7 @@ android:name="_R_G_L_2_G_D_3_P_0" android:pathData=" M-44.06 -38.17 C-42.87,-39.94 -41.39,-41.41 -39.51,-42.44 C-37.62,-43.47 -35.46,-44.05 -33.16,-44.05 C-30.88,-44.05 -28.72,-43.47 -26.85,-42.45 C-24.97,-41.43 -23.48,-39.97 -22.29,-38.21 " android:strokeAlpha="1" - android:strokeColor="@color/fingerprint_dialog_fingerprint_color" + android:strokeColor="@color/biometric_dialog_biometric_color" android:strokeLineCap="round" android:strokeLineJoin="round" android:strokeWidth="1.45" @@ -80,7 +80,7 @@ android:name="_R_G_L_2_G_D_4_P_0" android:pathData=" M-25.72 -45.45 C-27.99,-46.76 -30.43,-47.52 -33.28,-47.52 C-36.13,-47.52 -38.51,-46.74 -40.62,-45.45 " android:strokeAlpha="1" - android:strokeColor="@color/fingerprint_dialog_fingerprint_color" + android:strokeColor="@color/biometric_dialog_biometric_color" android:strokeLineCap="round" android:strokeLineJoin="round" android:strokeWidth="1.45" @@ -97,7 +97,7 @@ android:name="_R_G_L_1_G_D_0_P_0" android:pathData=" M0 -9 C4.97,-9 9,-4.97 9,0 C9,4.97 4.97,9 0,9 C-4.97,9 -9,4.97 -9,0 C-9,-4.97 -4.97,-9 0,-9c " android:strokeAlpha="1" - android:strokeColor="@color/fingerprint_dialog_error_color" + android:strokeColor="@color/biometric_dialog_error_color" android:strokeLineCap="round" android:strokeLineJoin="round" android:strokeWidth="2" @@ -118,7 +118,7 @@ @@ -131,7 +131,7 @@ diff --git a/packages/SystemUI/res/drawable/fingerprint_dialog_fp_to_error.xml b/packages/SystemUI/res/drawable/fingerprint_dialog_fp_to_error.xml index f682f87003dc8..fd0ab22b2f988 100644 --- a/packages/SystemUI/res/drawable/fingerprint_dialog_fp_to_error.xml +++ b/packages/SystemUI/res/drawable/fingerprint_dialog_fp_to_error.xml @@ -36,7 +36,7 @@ android:name="_R_G_L_3_G_D_0_P_0" android:pathData=" M-25.36 -24.41 C-25.93,-24.31 -26.49,-24.27 -26.81,-24.27 C-28.11,-24.27 -29.35,-24.62 -30.43,-25.4 C-32.11,-26.6 -33.2,-28.57 -33.2,-30.79 " android:strokeAlpha="1" - android:strokeColor="@color/fingerprint_dialog_fingerprint_color" + android:strokeColor="@color/biometric_dialog_biometric_color" android:strokeLineCap="round" android:strokeLineJoin="round" android:strokeWidth="1.45" @@ -47,7 +47,7 @@ android:name="_R_G_L_3_G_D_1_P_0" android:pathData=" M-36.14 -21.78 C-37.15,-22.98 -37.72,-23.7 -38.51,-25.29 C-39.33,-26.94 -39.82,-28.78 -39.82,-30.77 C-39.82,-34.43 -36.85,-37.4 -33.19,-37.4 C-29.52,-37.4 -26.55,-34.43 -26.55,-30.77 " android:strokeAlpha="1" - android:strokeColor="@color/fingerprint_dialog_fingerprint_color" + android:strokeColor="@color/biometric_dialog_biometric_color" android:strokeLineCap="round" android:strokeLineJoin="round" android:strokeWidth="1.45" @@ -58,7 +58,7 @@ android:name="_R_G_L_3_G_D_2_P_0" android:pathData=" M-42.19 -25.68 C-42.95,-27.82 -43.09,-29.54 -43.09,-30.8 C-43.09,-32.27 -42.84,-33.65 -42.27,-34.9 C-40.71,-38.35 -37.24,-40.75 -33.2,-40.75 C-27.71,-40.75 -23.26,-36.3 -23.26,-30.8 C-23.26,-28.97 -24.74,-27.49 -26.57,-27.49 C-28.4,-27.49 -29.89,-28.97 -29.89,-30.8 C-29.89,-32.64 -31.37,-34.12 -33.2,-34.12 C-35.04,-34.12 -36.52,-32.64 -36.52,-30.8 C-36.52,-28.23 -35.53,-25.92 -33.92,-24.22 C-32.69,-22.93 -31.48,-22.12 -29.44,-21.53 " android:strokeAlpha="1" - android:strokeColor="@color/fingerprint_dialog_fingerprint_color" + android:strokeColor="@color/biometric_dialog_biometric_color" android:strokeLineCap="round" android:strokeLineJoin="round" android:strokeWidth="1.45" @@ -69,7 +69,7 @@ android:name="_R_G_L_3_G_D_3_P_0" android:pathData=" M-44.06 -38.17 C-42.87,-39.94 -41.39,-41.41 -39.51,-42.44 C-37.62,-43.47 -35.46,-44.05 -33.16,-44.05 C-30.88,-44.05 -28.72,-43.47 -26.85,-42.45 C-24.97,-41.43 -23.48,-39.97 -22.29,-38.21 " android:strokeAlpha="1" - android:strokeColor="@color/fingerprint_dialog_fingerprint_color" + android:strokeColor="@color/biometric_dialog_biometric_color" android:strokeLineCap="round" android:strokeLineJoin="round" android:strokeWidth="1.45" @@ -80,7 +80,7 @@ android:name="_R_G_L_3_G_D_4_P_0" android:pathData=" M-25.72 -45.45 C-27.99,-46.76 -30.43,-47.52 -33.28,-47.52 C-36.13,-47.52 -38.51,-46.74 -40.62,-45.45 " android:strokeAlpha="1" - android:strokeColor="@color/fingerprint_dialog_fingerprint_color" + android:strokeColor="@color/biometric_dialog_biometric_color" android:strokeLineCap="round" android:strokeLineJoin="round" android:strokeWidth="1.45" @@ -101,7 +101,7 @@ android:name="_R_G_L_2_G_D_0_P_0" android:pathData=" M-25.36 -24.41 C-25.93,-24.31 -26.49,-24.27 -26.81,-24.27 C-28.11,-24.27 -29.35,-24.62 -30.43,-25.4 C-32.11,-26.6 -33.2,-28.57 -33.2,-30.79 " android:strokeAlpha="1" - android:strokeColor="@color/fingerprint_dialog_error_color" + android:strokeColor="@color/biometric_dialog_error_color" android:strokeLineCap="round" android:strokeLineJoin="round" android:strokeWidth="1.45" @@ -112,7 +112,7 @@ android:name="_R_G_L_2_G_D_1_P_0" android:pathData=" M-36.14 -21.78 C-37.15,-22.98 -37.72,-23.7 -38.51,-25.29 C-39.33,-26.94 -39.82,-28.78 -39.82,-30.77 C-39.82,-34.43 -36.85,-37.4 -33.19,-37.4 C-29.52,-37.4 -26.55,-34.43 -26.55,-30.77 " android:strokeAlpha="1" - android:strokeColor="@color/fingerprint_dialog_error_color" + android:strokeColor="@color/biometric_dialog_error_color" android:strokeLineCap="round" android:strokeLineJoin="round" android:strokeWidth="1.45" @@ -123,7 +123,7 @@ android:name="_R_G_L_2_G_D_2_P_0" android:pathData=" M-42.19 -25.68 C-42.95,-27.82 -43.09,-29.54 -43.09,-30.8 C-43.09,-32.27 -42.84,-33.65 -42.27,-34.9 C-40.71,-38.35 -37.24,-40.75 -33.2,-40.75 C-27.71,-40.75 -23.26,-36.3 -23.26,-30.8 C-23.26,-28.97 -24.74,-27.49 -26.57,-27.49 C-28.4,-27.49 -29.89,-28.97 -29.89,-30.8 C-29.89,-32.64 -31.37,-34.12 -33.2,-34.12 C-35.04,-34.12 -36.52,-32.64 -36.52,-30.8 C-36.52,-28.23 -35.53,-25.92 -33.92,-24.22 C-32.69,-22.93 -31.48,-22.12 -29.44,-21.53 " android:strokeAlpha="1" - android:strokeColor="@color/fingerprint_dialog_error_color" + android:strokeColor="@color/biometric_dialog_error_color" android:strokeLineCap="round" android:strokeLineJoin="round" android:strokeWidth="1.45" @@ -134,7 +134,7 @@ android:name="_R_G_L_2_G_D_3_P_0" android:pathData=" M-44.06 -38.17 C-42.87,-39.94 -41.39,-41.41 -39.51,-42.44 C-37.62,-43.47 -35.46,-44.05 -33.16,-44.05 C-30.88,-44.05 -28.72,-43.47 -26.85,-42.45 C-24.97,-41.43 -23.48,-39.97 -22.29,-38.21 " android:strokeAlpha="1" - android:strokeColor="@color/fingerprint_dialog_error_color" + android:strokeColor="@color/biometric_dialog_error_color" android:strokeLineCap="round" android:strokeLineJoin="round" android:strokeWidth="1.45" @@ -145,7 +145,7 @@ android:name="_R_G_L_2_G_D_4_P_0" android:pathData=" M-25.72 -45.45 C-27.99,-46.76 -30.43,-47.52 -33.28,-47.52 C-36.13,-47.52 -38.51,-46.74 -40.62,-45.45 " android:strokeAlpha="1" - android:strokeColor="@color/fingerprint_dialog_error_color" + android:strokeColor="@color/biometric_dialog_error_color" android:strokeLineCap="round" android:strokeLineJoin="round" android:strokeWidth="1.45" @@ -162,7 +162,7 @@ android:name="_R_G_L_1_G_D_0_P_0" android:pathData=" M0 -9 C4.97,-9 9,-4.97 9,0 C9,4.97 4.97,9 0,9 C-4.97,9 -9,4.97 -9,0 C-9,-4.97 -4.97,-9 0,-9c " android:strokeAlpha="1" - android:strokeColor="@color/fingerprint_dialog_error_color" + android:strokeColor="@color/biometric_dialog_error_color" android:strokeLineCap="round" android:strokeLineJoin="round" android:strokeWidth="2" @@ -183,7 +183,7 @@ @@ -196,7 +196,7 @@ diff --git a/packages/SystemUI/res/layout/fingerprint_dialog.xml b/packages/SystemUI/res/layout/fingerprint_dialog.xml index 1bdaf6e335447..06d1e0b1c980c 100644 --- a/packages/SystemUI/res/layout/fingerprint_dialog.xml +++ b/packages/SystemUI/res/layout/fingerprint_dialog.xml @@ -19,7 +19,7 @@ android:layout_width="match_parent" android:layout_height="match_parent" android:gravity="bottom" - android:background="@color/fingerprint_dialog_dim_color" + android:background="@color/biometric_dialog_dim_color" android:orientation="vertical"> @@ -63,7 +63,7 @@ android:singleLine="true" android:ellipsize="marquee" android:marqueeRepeatLimit="marquee_forever" - android:textColor="@color/fingerprint_dialog_text_dark_color"/> + android:textColor="@color/biometric_dialog_text_dark_color"/> + android:textColor="@color/biometric_dialog_text_dark_color"/> + android:textColor="@color/biometric_dialog_text_dark_color"/> + android:textColor="@color/biometric_dialog_text_light_color"/> #ffffffff #ffdadce0 - - #ffffffff - #dd000000 - #89000000 - #80000000 - #fff44336 - #ff008577 + + #ffffffff + #dd000000 + #89000000 + #80000000 + #fff44336 + #ff008577 #ccffffff diff --git a/packages/SystemUI/res/values/dimens.xml b/packages/SystemUI/res/values/dimens.xml index c168d4e6d7b29..d21f6d9ad45a9 100644 --- a/packages/SystemUI/res/values/dimens.xml +++ b/packages/SystemUI/res/values/dimens.xml @@ -982,10 +982,10 @@ the regular notification, when we have remote input history texts present. --> 60dp - - 64dp + + 64dp + 4dp 350dp - 4dp 0dp diff --git a/packages/SystemUI/src/com/android/systemui/biometrics/BiometricDialogImpl.java b/packages/SystemUI/src/com/android/systemui/biometrics/BiometricDialogImpl.java index 7359daa9dc6db..327eba74f15d5 100644 --- a/packages/SystemUI/src/com/android/systemui/biometrics/BiometricDialogImpl.java +++ b/packages/SystemUI/src/com/android/systemui/biometrics/BiometricDialogImpl.java @@ -116,7 +116,7 @@ public class BiometricDialogImpl extends SystemUI implements CommandQueue.Callba } getComponent(CommandQueue.class).addCallbacks(this); mWindowManager = (WindowManager) mContext.getSystemService(Context.WINDOW_SERVICE); - mDialogView = new BiometricDialogView(mContext, mCallback); + mDialogView = new FingerprintDialogView(mContext, mCallback); } @Override diff --git a/packages/SystemUI/src/com/android/systemui/biometrics/BiometricDialogView.java b/packages/SystemUI/src/com/android/systemui/biometrics/BiometricDialogView.java index 9ebd54b670ebb..50ee88c7ff311 100644 --- a/packages/SystemUI/src/com/android/systemui/biometrics/BiometricDialogView.java +++ b/packages/SystemUI/src/com/android/systemui/biometrics/BiometricDialogView.java @@ -19,8 +19,6 @@ package com.android.systemui.biometrics; import android.content.Context; import android.graphics.Color; import android.graphics.PixelFormat; -import android.graphics.drawable.AnimatedVectorDrawable; -import android.graphics.drawable.Drawable; import android.hardware.biometrics.BiometricPrompt; import android.os.Binder; import android.os.Bundle; @@ -38,7 +36,6 @@ import android.view.ViewGroup; import android.view.WindowManager; import android.view.animation.Interpolator; import android.widget.Button; -import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.TextView; @@ -46,11 +43,9 @@ import com.android.systemui.Interpolators; import com.android.systemui.R; /** - * This class loads the view for the system-provided dialog. The view consists of: - * Application Icon, Title, Subtitle, Description, Fingerprint Icon, Error/Help message area, - * and positive/negative buttons. + * Abstract base class. Shows a dialog for BiometricPrompt. */ -public class BiometricDialogView extends LinearLayout { +public abstract class BiometricDialogView extends LinearLayout { private static final String TAG = "BiometricDialogView"; @@ -59,10 +54,10 @@ public class BiometricDialogView extends LinearLayout { private static final int MSG_CLEAR_MESSAGE = 1; - private static final int STATE_NONE = 0; - private static final int STATE_FINGERPRINT = 1; - private static final int STATE_FINGERPRINT_ERROR = 2; - private static final int STATE_FINGERPRINT_AUTHENTICATED = 3; + protected static final int STATE_NONE = 0; + protected static final int STATE_AUTHENTICATING = 1; + protected static final int STATE_ERROR = 2; + protected static final int STATE_AUTHENTICATED = 3; private final IBinder mWindowToken = new Binder(); private final Interpolator mLinearOutSlowIn; @@ -70,7 +65,6 @@ public class BiometricDialogView extends LinearLayout { private final float mAnimationTranslationOffset; private final int mErrorColor; private final int mTextColor; - private final int mFingerprintColor; private final float mDisplayWidth; private final DialogViewCallback mCallback; @@ -82,6 +76,11 @@ public class BiometricDialogView extends LinearLayout { private boolean mAnimatingAway; private boolean mWasForceRemoved; + protected abstract int getLayoutResourceId(); + protected abstract float getAnimationTranslationOffset(); + protected abstract void updateIcon(int lastState, int newState); + protected abstract int getHintStringResource(); + private final Runnable mShowAnimationRunnable = new Runnable() { @Override public void run() { @@ -119,14 +118,11 @@ public class BiometricDialogView extends LinearLayout { mCallback = callback; mLinearOutSlowIn = Interpolators.LINEAR_OUT_SLOW_IN; mWindowManager = (WindowManager) mContext.getSystemService(Context.WINDOW_SERVICE); - mAnimationTranslationOffset = getResources() - .getDimension(R.dimen.fingerprint_dialog_animation_translation_offset); + mAnimationTranslationOffset = getAnimationTranslationOffset(); mErrorColor = Color.parseColor( - getResources().getString(R.color.fingerprint_dialog_error_color)); + getResources().getString(R.color.biometric_dialog_error_color)); mTextColor = Color.parseColor( - getResources().getString(R.color.fingerprint_dialog_text_light_color)); - mFingerprintColor = Color.parseColor( - getResources().getString(R.color.fingerprint_dialog_fingerprint_color)); + getResources().getString(R.color.biometric_dialog_text_light_color)); DisplayMetrics metrics = new DisplayMetrics(); mWindowManager.getDefaultDisplay().getMetrics(metrics); @@ -134,7 +130,7 @@ public class BiometricDialogView extends LinearLayout { // Create the dialog LayoutInflater factory = LayoutInflater.from(getContext()); - mLayout = (ViewGroup) factory.inflate(R.layout.fingerprint_dialog, this, false); + mLayout = (ViewGroup) factory.inflate(getLayoutResourceId(), this, false); addView(mLayout); mDialog = mLayout.findViewById(R.id.dialog); @@ -195,7 +191,7 @@ public class BiometricDialogView extends LinearLayout { mDialog.getLayoutParams().width = (int) mDisplayWidth; mLastState = STATE_NONE; - updateFingerprintIcon(STATE_FINGERPRINT); + updateState(STATE_AUTHENTICATING); title.setText(mBundle.getCharSequence(BiometricPrompt.KEY_TITLE)); title.setSelected(true); @@ -303,17 +299,21 @@ public class BiometricDialogView extends LinearLayout { mBundle = bundle; } + public ViewGroup getLayout() { + return mLayout; + } + // Clears the temporary message and shows the help message. private void handleClearMessage() { - updateFingerprintIcon(STATE_FINGERPRINT); - mErrorText.setText(R.string.fingerprint_dialog_touch_sensor); + updateState(STATE_AUTHENTICATING); + mErrorText.setText(getHintStringResource()); mErrorText.setTextColor(mTextColor); } // Shows an error/help message private void showTemporaryMessage(String message) { mHandler.removeMessages(MSG_CLEAR_MESSAGE); - updateFingerprintIcon(STATE_FINGERPRINT_ERROR); + updateState(STATE_ERROR); mErrorText.setText(message); mErrorText.setTextColor(mErrorColor); mErrorText.setContentDescription(message); @@ -330,61 +330,11 @@ public class BiometricDialogView extends LinearLayout { mCallback.onErrorShown(); } - private void updateFingerprintIcon(int newState) { - Drawable icon = getAnimationForTransition(mLastState, newState); - - if (icon == null) { - Log.e(TAG, "Animation not found"); - return; - } - - final AnimatedVectorDrawable animation = icon instanceof AnimatedVectorDrawable - ? (AnimatedVectorDrawable) icon - : null; - - final ImageView fingerprint_icon = mLayout.findViewById(R.id.fingerprint_icon); - fingerprint_icon.setImageDrawable(icon); - - if (animation != null && shouldAnimateForTransition(mLastState, newState)) { - animation.forceAnimationOnUI(); - animation.start(); - } - + private void updateState(int newState) { + updateIcon(mLastState, newState); mLastState = newState; } - private boolean shouldAnimateForTransition(int oldState, int newState) { - if (oldState == STATE_NONE && newState == STATE_FINGERPRINT) { - return false; - } else if (oldState == STATE_FINGERPRINT && newState == STATE_FINGERPRINT_ERROR) { - return true; - } else if (oldState == STATE_FINGERPRINT_ERROR && newState == STATE_FINGERPRINT) { - return true; - } else if (oldState == STATE_FINGERPRINT && newState == STATE_FINGERPRINT_AUTHENTICATED) { - // TODO(b/77328470): add animation when fingerprint is authenticated - return false; - } - return false; - } - - private Drawable getAnimationForTransition(int oldState, int newState) { - int iconRes; - if (oldState == STATE_NONE && newState == STATE_FINGERPRINT) { - iconRes = R.drawable.fingerprint_dialog_fp_to_error; - } else if (oldState == STATE_FINGERPRINT && newState == STATE_FINGERPRINT_ERROR) { - iconRes = R.drawable.fingerprint_dialog_fp_to_error; - } else if (oldState == STATE_FINGERPRINT_ERROR && newState == STATE_FINGERPRINT) { - iconRes = R.drawable.fingerprint_dialog_error_to_fp; - } else if (oldState == STATE_FINGERPRINT && newState == STATE_FINGERPRINT_AUTHENTICATED) { - // TODO(b/77328470): add animation when fingerprint is authenticated - iconRes = R.drawable.fingerprint_dialog_error_to_fp; - } - else { - return null; - } - return mContext.getDrawable(iconRes); - } - public WindowManager.LayoutParams getLayoutParams() { final WindowManager.LayoutParams lp = new WindowManager.LayoutParams( ViewGroup.LayoutParams.MATCH_PARENT, diff --git a/packages/SystemUI/src/com/android/systemui/biometrics/FingerprintDialogView.java b/packages/SystemUI/src/com/android/systemui/biometrics/FingerprintDialogView.java new file mode 100644 index 0000000000000..9033322069674 --- /dev/null +++ b/packages/SystemUI/src/com/android/systemui/biometrics/FingerprintDialogView.java @@ -0,0 +1,108 @@ +/* + * Copyright (C) 2018 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License + */ + +package com.android.systemui.biometrics; + +import android.content.Context; +import android.graphics.drawable.AnimatedVectorDrawable; +import android.graphics.drawable.Drawable; +import android.util.Log; +import android.widget.ImageView; + +import com.android.systemui.R; + +/** + * This class loads the view for the system-provided dialog. The view consists of: + * Application Icon, Title, Subtitle, Description, Fingerprint Icon, Error/Help message area, + * and positive/negative buttons. + */ +public class FingerprintDialogView extends BiometricDialogView { + private static final String TAG = "FingerprintDialogView"; + + @Override + protected int getLayoutResourceId() { + return R.layout.fingerprint_dialog; + } + + @Override + protected int getHintStringResource() { + return R.string.fingerprint_dialog_touch_sensor; + } + + @Override + protected float getAnimationTranslationOffset() { + return getResources() + .getDimension(R.dimen.fingerprint_dialog_animation_translation_offset); + } + + @Override + protected void updateIcon(int lastState, int newState) { + Drawable icon = getAnimationForTransition(lastState, newState); + + if (icon == null) { + Log.e(TAG, "Animation not found"); + return; + } + + final AnimatedVectorDrawable animation = icon instanceof AnimatedVectorDrawable + ? (AnimatedVectorDrawable) icon + : null; + + final ImageView fingerprint_icon = getLayout().findViewById(R.id.fingerprint_icon); + fingerprint_icon.setImageDrawable(icon); + + if (animation != null && shouldAnimateForTransition(lastState, newState)) { + animation.forceAnimationOnUI(); + animation.start(); + } + } + + public FingerprintDialogView(Context context, + DialogViewCallback callback) { + super(context, callback); + } + + private boolean shouldAnimateForTransition(int oldState, int newState) { + if (oldState == STATE_NONE && newState == STATE_AUTHENTICATING) { + return false; + } else if (oldState == STATE_AUTHENTICATING && newState == STATE_ERROR) { + return true; + } else if (oldState == STATE_ERROR && newState == STATE_AUTHENTICATING) { + return true; + } else if (oldState == STATE_AUTHENTICATING && newState == STATE_AUTHENTICATED) { + // TODO(b/77328470): add animation when fingerprint is authenticated + return false; + } + return false; + } + + private Drawable getAnimationForTransition(int oldState, int newState) { + int iconRes; + if (oldState == STATE_NONE && newState == STATE_AUTHENTICATING) { + iconRes = R.drawable.fingerprint_dialog_fp_to_error; + } else if (oldState == STATE_AUTHENTICATING && newState == STATE_ERROR) { + iconRes = R.drawable.fingerprint_dialog_fp_to_error; + } else if (oldState == STATE_ERROR && newState == STATE_AUTHENTICATING) { + iconRes = R.drawable.fingerprint_dialog_error_to_fp; + } else if (oldState == STATE_AUTHENTICATING && newState == STATE_AUTHENTICATED) { + // TODO(b/77328470): add animation when fingerprint is authenticated + iconRes = R.drawable.fingerprint_dialog_error_to_fp; + } else { + return null; + } + return mContext.getDrawable(iconRes); + } +} \ No newline at end of file From 6cf54e8190c35d978970d7795f2783dc46c3571b Mon Sep 17 00:00:00 2001 From: Kevin Chyn Date: Tue, 18 Sep 2018 19:13:27 -0700 Subject: [PATCH 3/3] 3/n: Add FaceDialogView and "confirmation" plumbing This change adds plumbing from Service to SystemUI for requiring user confirmation (or not). This change also fixes some layout bugs that were hard to notice. Bug: 111461540 Fixes: 113130114 Fixes: 116135579 Test: With confirmation, crypto operation does not work until token is added to Keystore Test: Without confirmation, crypto operation works when biometric is authenticated Test: BiometricPromptDemo works, UI elements are all correct Test: Talkback messages are correct Change-Id: I2c05577699a29c09777cae4db6c7334c1e6bc179 --- .../android/hardware/face/FaceManager.java | 12 +- .../android/hardware/face/IFaceService.aidl | 4 +- .../internal/statusbar/IStatusBar.aidl | 3 +- .../internal/statusbar/IStatusBarService.aidl | 3 +- core/res/res/values/strings.xml | 6 + core/res/res/values/symbols.xml | 3 + ..._dialog_bg.xml => biometric_dialog_bg.xml} | 0 .../res/drawable/face_dialog_icon.xml | 24 ++++ ...rprint_dialog.xml => biometric_dialog.xml} | 38 ++++--- packages/SystemUI/res/values/dimens.xml | 2 +- packages/SystemUI/res/values/integers.xml | 2 +- packages/SystemUI/res/values/strings.xml | 14 ++- .../biometrics/BiometricDialogImpl.java | 64 +++++++---- .../biometrics/BiometricDialogView.java | 43 ++++--- .../systemui/biometrics/FaceDialogView.java | 62 ++++++++++ .../biometrics/FingerprintDialogView.java | 21 ++-- .../systemui/statusbar/CommandQueue.java | 9 +- .../biometrics/AuthenticationClient.java | 107 +++++++++++++++--- .../biometrics/BiometricPromptService.java | 10 +- .../server/biometrics/BiometricService.java | 19 ++-- .../server/biometrics/ClientMonitor.java | 3 +- .../server/biometrics/EnrollClient.java | 3 +- .../server/biometrics/EnumerateClient.java | 4 +- .../server/biometrics/RemovalClient.java | 4 +- .../server/biometrics/face/FaceService.java | 19 ++-- .../fingerprint/FingerprintService.java | 12 +- .../statusbar/StatusBarManagerService.java | 5 +- 27 files changed, 364 insertions(+), 132 deletions(-) rename packages/SystemUI/res/drawable/{fingerprint_dialog_bg.xml => biometric_dialog_bg.xml} (100%) create mode 100644 packages/SystemUI/res/drawable/face_dialog_icon.xml rename packages/SystemUI/res/layout/{fingerprint_dialog.xml => biometric_dialog.xml} (85%) create mode 100644 packages/SystemUI/src/com/android/systemui/biometrics/FaceDialogView.java diff --git a/core/java/android/hardware/face/FaceManager.java b/core/java/android/hardware/face/FaceManager.java index 20e0116a04735..66613ea503572 100644 --- a/core/java/android/hardware/face/FaceManager.java +++ b/core/java/android/hardware/face/FaceManager.java @@ -521,16 +521,16 @@ public class FaceManager implements BiometricAuthenticator, BiometricFaceConstan */ public static String getErrorString(Context context, int errMsg, int vendorCode) { switch (errMsg) { - case FACE_ERROR_HW_UNAVAILABLE: - return context.getString( - com.android.internal.R.string.face_error_hw_not_available); case FACE_ERROR_UNABLE_TO_PROCESS: return context.getString( com.android.internal.R.string.face_error_unable_to_process); - case FACE_ERROR_TIMEOUT: - return context.getString(com.android.internal.R.string.face_error_timeout); + case FACE_ERROR_HW_UNAVAILABLE: + return context.getString( + com.android.internal.R.string.face_error_hw_not_available); case FACE_ERROR_NO_SPACE: return context.getString(com.android.internal.R.string.face_error_no_space); + case FACE_ERROR_TIMEOUT: + return context.getString(com.android.internal.R.string.face_error_timeout); case FACE_ERROR_CANCELED: return context.getString(com.android.internal.R.string.face_error_canceled); case FACE_ERROR_LOCKOUT: @@ -538,6 +538,8 @@ public class FaceManager implements BiometricAuthenticator, BiometricFaceConstan case FACE_ERROR_LOCKOUT_PERMANENT: return context.getString( com.android.internal.R.string.face_error_lockout_permanent); + case FACE_ERROR_USER_CANCELED: + return context.getString(com.android.internal.R.string.face_error_user_canceled); case FACE_ERROR_NOT_ENROLLED: return context.getString(com.android.internal.R.string.face_error_not_enrolled); case FACE_ERROR_HW_NOT_PRESENT: diff --git a/core/java/android/hardware/face/IFaceService.aidl b/core/java/android/hardware/face/IFaceService.aidl index dd995c985286e..a0122145c6e6e 100644 --- a/core/java/android/hardware/face/IFaceService.aidl +++ b/core/java/android/hardware/face/IFaceService.aidl @@ -34,8 +34,8 @@ interface IFaceService { // This method invokes the BiometricDialog. The arguments are almost the same as above, // but should only be called from (BiometricPromptService). - void authenticateFromService(IBinder token, long sessionId, int userId, - IBiometricPromptServiceReceiver receiver, int flags, String opPackageName, + void authenticateFromService(boolean requireConfirmation, IBinder token, long sessionId, + int userId, IBiometricPromptServiceReceiver receiver, int flags, String opPackageName, in Bundle bundle, IBiometricPromptReceiver dialogReceiver, int callingUid, int callingPid, int callingUserId); diff --git a/core/java/com/android/internal/statusbar/IStatusBar.aidl b/core/java/com/android/internal/statusbar/IStatusBar.aidl index c4214cf19fa92..9b8f120ec08d2 100644 --- a/core/java/com/android/internal/statusbar/IStatusBar.aidl +++ b/core/java/com/android/internal/statusbar/IStatusBar.aidl @@ -141,7 +141,8 @@ oneway interface IStatusBar void showShutdownUi(boolean isReboot, String reason); // Used to show the dialog when BiometricService starts authentication - void showBiometricDialog(in Bundle bundle, IBiometricPromptReceiver receiver, int type); + void showBiometricDialog(in Bundle bundle, IBiometricPromptReceiver receiver, int type, + boolean requireConfirmation); // Used to hide the dialog when a biometric is authenticated void onBiometricAuthenticated(); // Used to set a temporary message, e.g. fingerprint not recognized, finger moved too fast, etc diff --git a/core/java/com/android/internal/statusbar/IStatusBarService.aidl b/core/java/com/android/internal/statusbar/IStatusBarService.aidl index e48e733051913..90f2002d7363e 100644 --- a/core/java/com/android/internal/statusbar/IStatusBarService.aidl +++ b/core/java/com/android/internal/statusbar/IStatusBarService.aidl @@ -91,7 +91,8 @@ interface IStatusBarService void showPinningEscapeToast(); // Used to show the dialog when BiometricService starts authentication - void showBiometricDialog(in Bundle bundle, IBiometricPromptReceiver receiver, int type); + void showBiometricDialog(in Bundle bundle, IBiometricPromptReceiver receiver, int type, + boolean requireConfirmation); // Used to hide the dialog when a biometric is authenticated void onBiometricAuthenticated(); // Used to set a temporary message, e.g. fingerprint not recognized, finger moved too fast, etc diff --git a/core/res/res/values/strings.xml b/core/res/res/values/strings.xml index 64620f33b2df7..6d0127a4bba13 100644 --- a/core/res/res/values/strings.xml +++ b/core/res/res/values/strings.xml @@ -1439,6 +1439,10 @@ Not recognized Fingerprint authenticated + + Face authenticated + + Face authenticated, please press confirm Fingerprint hardware not available. @@ -1516,6 +1520,8 @@ Face can\u2019t be stored. Face operation canceled. + + Face authentication canceled by user. Too many attempts. Try again later. diff --git a/core/res/res/values/symbols.xml b/core/res/res/values/symbols.xml index 7b8eceda9370c..cf859867f21c3 100644 --- a/core/res/res/values/symbols.xml +++ b/core/res/res/values/symbols.xml @@ -2429,6 +2429,7 @@ + @@ -2446,6 +2447,8 @@ + + diff --git a/packages/SystemUI/res/drawable/fingerprint_dialog_bg.xml b/packages/SystemUI/res/drawable/biometric_dialog_bg.xml similarity index 100% rename from packages/SystemUI/res/drawable/fingerprint_dialog_bg.xml rename to packages/SystemUI/res/drawable/biometric_dialog_bg.xml diff --git a/packages/SystemUI/res/drawable/face_dialog_icon.xml b/packages/SystemUI/res/drawable/face_dialog_icon.xml new file mode 100644 index 0000000000000..6d28b5a105f2e --- /dev/null +++ b/packages/SystemUI/res/drawable/face_dialog_icon.xml @@ -0,0 +1,24 @@ + + + + + + \ No newline at end of file diff --git a/packages/SystemUI/res/layout/fingerprint_dialog.xml b/packages/SystemUI/res/layout/biometric_dialog.xml similarity index 85% rename from packages/SystemUI/res/layout/fingerprint_dialog.xml rename to packages/SystemUI/res/layout/biometric_dialog.xml index 06d1e0b1c980c..0417e2ede2d39 100644 --- a/packages/SystemUI/res/layout/fingerprint_dialog.xml +++ b/packages/SystemUI/res/layout/biometric_dialog.xml @@ -47,7 +47,7 @@ android:layout_height="wrap_content" android:orientation="vertical" android:elevation="2dp" - android:background="@drawable/fingerprint_dialog_bg"> + android:background="@drawable/biometric_dialog_bg"> + android:scaleType="fitXY" /> @@ -133,20 +131,26 @@ android:layout_width="wrap_content" android:layout_height="match_parent" style="@*android:style/Widget.DeviceDefault.Button.Borderless.Colored" - android:layout_marginStart="-12dp" - android:gravity="start|center_vertical" + android:gravity="center" android:maxLines="2" /> +