From e30af88c936b736c8c21791b609d7c32350e5711 Mon Sep 17 00:00:00 2001 From: Ilya Matyukhin Date: Thu, 16 Sep 2021 16:33:28 -0700 Subject: [PATCH] Fix NPE for UDFPS devices without HBM Bug: 200295570 Test: run with a null HbmProvider on a UDFPS device Change-Id: Id89552d3228b4770331e0eda558f0f97101ad8ca --- .../systemui/biometrics/UdfpsView.java | 30 +++++++++++-------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsView.java b/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsView.java index 15f77ffc08fd4..8a213ec502e43 100644 --- a/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsView.java +++ b/packages/SystemUI/src/com/android/systemui/biometrics/UdfpsView.java @@ -239,18 +239,20 @@ public class UdfpsView extends FrameLayout implements DozeReceiver, UdfpsIllumin if (mGhbmView != null && surface == null) { Log.e(TAG, "doIlluminate | surface must be non-null for GHBM"); } - mHbmProvider.enableHbm(mHbmType, surface, () -> { - if (mGhbmView != null) { - mGhbmView.drawIlluminationDot(mSensorRect); - } - if (onIlluminatedRunnable != null) { - // No framework API can reliably tell when a frame reaches the panel. A timeout - // is the safest solution. - postDelayed(onIlluminatedRunnable, mOnIlluminatedDelayMs); - } else { - Log.w(TAG, "doIlluminate | onIlluminatedRunnable is null"); - } - }); + if (mHbmProvider != null) { + mHbmProvider.enableHbm(mHbmType, surface, () -> { + if (mGhbmView != null) { + mGhbmView.drawIlluminationDot(mSensorRect); + } + if (onIlluminatedRunnable != null) { + // No framework API can reliably tell when a frame reaches the panel. A timeout + // is the safest solution. + postDelayed(onIlluminatedRunnable, mOnIlluminatedDelayMs); + } else { + Log.w(TAG, "doIlluminate | onIlluminatedRunnable is null"); + } + }); + } } @Override @@ -263,6 +265,8 @@ public class UdfpsView extends FrameLayout implements DozeReceiver, UdfpsIllumin mGhbmView.setGhbmIlluminationListener(null); mGhbmView.setVisibility(View.INVISIBLE); } - mHbmProvider.disableHbm(null /* onHbmDisabled */); + if (mHbmProvider != null) { + mHbmProvider.disableHbm(null /* onHbmDisabled */); + } } }