summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Kevin Chyn <kchyn@google.com> 2021-03-04 17:53:11 -0800
committer Kevin Chyn <kchyn@google.com> 2021-03-04 18:14:31 -0800
commit9e5e59b55201d50f9c251c1a2c72231c9bb21808 (patch)
tree0ec78f837b7180ceae248827ce109cd40fa4560f
parent4c1410fafdfe1c2964b1586782b2777e8eee9e30 (diff)
Fix NPE crashes during UDFPS BiometricPrompt
BiometricPrompt for UDFPS used to be working by coincidence. We were always passing null into non-null places. Just it actually broke now. Fixes: 181884785 Test: manual Test: atest com.android.systemui.biometrics Change-Id: Iae22966f0a3ea0bfc543cd01e4b3373d1cead937
-rw-r--r--packages/SystemUI/res/layout/udfps_animation_view_bp.xml22
-rw-r--r--packages/SystemUI/src/com/android/systemui/biometrics/UdfpsAnimationView.java13
-rw-r--r--packages/SystemUI/src/com/android/systemui/biometrics/UdfpsAnimationViewBp.java42
-rw-r--r--packages/SystemUI/src/com/android/systemui/biometrics/UdfpsController.java22
4 files changed, 90 insertions, 9 deletions
diff --git a/packages/SystemUI/res/layout/udfps_animation_view_bp.xml b/packages/SystemUI/res/layout/udfps_animation_view_bp.xml
new file mode 100644
index 000000000000..0cfbf2e61dd1
--- /dev/null
+++ b/packages/SystemUI/res/layout/udfps_animation_view_bp.xml
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ ~ Copyright (C) 2021 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.
+ -->
+<com.android.systemui.biometrics.UdfpsAnimationViewBp
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@+id/udfps_animation_view"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent">
+</com.android.systemui.biometrics.UdfpsAnimationViewBp>
diff --git a/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsAnimationView.java b/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsAnimationView.java
index f4dd181eb329..6666c8dda527 100644
--- a/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsAnimationView.java
+++ b/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsAnimationView.java
@@ -62,7 +62,10 @@ public abstract class UdfpsAnimationView extends FrameLayout implements DozeRece
@Override
protected void onDetachedFromWindow() {
super.onDetachedFromWindow();
- getUdfpsAnimation().onDestroy();
+
+ if (getUdfpsAnimation() != null) {
+ getUdfpsAnimation().onDestroy();
+ }
}
private int expansionToAlpha(float expansion) {
@@ -78,11 +81,19 @@ public abstract class UdfpsAnimationView extends FrameLayout implements DozeRece
}
void onIlluminationStarting() {
+ if (getUdfpsAnimation() == null) {
+ return;
+ }
+
getUdfpsAnimation().setIlluminationShowing(true);
postInvalidate();
}
void onIlluminationStopped() {
+ if (getUdfpsAnimation() == null) {
+ return;
+ }
+
getUdfpsAnimation().setIlluminationShowing(false);
postInvalidate();
}
diff --git a/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsAnimationViewBp.java b/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsAnimationViewBp.java
new file mode 100644
index 000000000000..515b442b61f6
--- /dev/null
+++ b/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsAnimationViewBp.java
@@ -0,0 +1,42 @@
+/*
+ * Copyright (C) 2021 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.util.AttributeSet;
+
+import androidx.annotation.Nullable;
+
+/**
+ * Class that coordinates non-HBM animations during BiometricPrompt.
+ *
+ * Note that {@link AuthBiometricUdfpsView} also shows UDFPS animations. At some point we should
+ * de-dupe this if necessary. This will probably happen once the top-level TODO in UdfpsController
+ * is completed (inflate operation-specific views, instead of inflating generic udfps_view and
+ * adding operation-specific animations to it).
+ */
+public class UdfpsAnimationViewBp extends UdfpsAnimationView {
+ public UdfpsAnimationViewBp(Context context, @Nullable AttributeSet attrs) {
+ super(context, attrs);
+ }
+
+ @Nullable
+ @Override
+ protected UdfpsAnimation getUdfpsAnimation() {
+ return null;
+ }
+}
diff --git a/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsController.java b/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsController.java
index e1d7eb3cbb19..be27b24c90ac 100644
--- a/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsController.java
+++ b/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsController.java
@@ -358,23 +358,29 @@ public class UdfpsController implements DozeReceiver, HbmCallback {
switch (reason) {
case IUdfpsOverlayController.REASON_ENROLL_FIND_SENSOR:
case IUdfpsOverlayController.REASON_ENROLL_ENROLLING: {
- final UdfpsAnimationViewEnroll animation = (UdfpsAnimationViewEnroll)
+ final UdfpsAnimationViewEnroll view = (UdfpsAnimationViewEnroll)
inflater.inflate(R.layout.udfps_animation_view_enroll, null, false);
- animation.setEnrollHelper(mEnrollHelper);
- return animation;
+ view.setEnrollHelper(mEnrollHelper);
+ return view;
+ }
+
+ case IUdfpsOverlayController.REASON_AUTH_BP: {
+ final UdfpsAnimationViewBp view = (UdfpsAnimationViewBp)
+ inflater.inflate(R.layout.udfps_animation_view_bp, null, false);
+ return view;
}
case IUdfpsOverlayController.REASON_AUTH_FPM_KEYGUARD: {
- final UdfpsAnimationViewKeyguard animation = (UdfpsAnimationViewKeyguard)
+ final UdfpsAnimationViewKeyguard view = (UdfpsAnimationViewKeyguard)
inflater.inflate(R.layout.udfps_animation_view_keyguard, null, false);
- animation.setStatusBarStateController(mStatusBarStateController);
- return animation;
+ view.setStatusBarStateController(mStatusBarStateController);
+ return view;
}
case IUdfpsOverlayController.REASON_AUTH_FPM_OTHER: {
- final UdfpsAnimationViewFpmOther animation = (UdfpsAnimationViewFpmOther)
+ final UdfpsAnimationViewFpmOther view = (UdfpsAnimationViewFpmOther)
inflater.inflate(R.layout.udfps_animation_view_fpm_other, null, false);
- return animation;
+ return view;
}
default: