From 16e0cbc048c575ee60f9944127797690b2b2e15e Mon Sep 17 00:00:00 2001 From: kwaky Date: Tue, 28 Apr 2020 22:53:15 -0700 Subject: [PATCH] Add mBouncer null checks for view-related requests. CarKeytuardView is inflated when CarKeyguardView is first started, and mBouncer is assigned a value onFinishInflated. Since some of the view-related requests that reference mBouncer could be called before that event, we need to add null checks for them. Such a check is redundant for methods that check for mShowing, since if mShowing is true, it is guaranteed that mBouncer is assigned a value. Bug: 154928953 Test: Manual and Existing Unit Tests Change-Id: I796e8bc73459df3b2a0374818556262ebc2ea237 --- .../car/keyguard/CarKeyguardViewController.java | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/packages/CarSystemUI/src/com/android/systemui/car/keyguard/CarKeyguardViewController.java b/packages/CarSystemUI/src/com/android/systemui/car/keyguard/CarKeyguardViewController.java index 6d659f1925939..baa6ac945a8a1 100644 --- a/packages/CarSystemUI/src/com/android/systemui/car/keyguard/CarKeyguardViewController.java +++ b/packages/CarSystemUI/src/com/android/systemui/car/keyguard/CarKeyguardViewController.java @@ -151,7 +151,9 @@ public class CarKeyguardViewController extends OverlayViewController implements @Override public void notifyKeyguardAuthenticated(boolean strongAuth) { - mBouncer.notifyKeyguardAuthenticated(strongAuth); + if (mBouncer != null) { + mBouncer.notifyKeyguardAuthenticated(strongAuth); + } } @Override @@ -204,11 +206,15 @@ public class CarKeyguardViewController extends OverlayViewController implements @Override public void onFinishedGoingToSleep() { - mBouncer.onScreenTurnedOff(); + if (mBouncer != null) { + mBouncer.onScreenTurnedOff(); + } } @Override public void onCancelClicked() { + if (!mShowing) return; + getOverlayViewGlobalStateController().setWindowFocusable(/* focusable= */ false); getOverlayViewGlobalStateController().setWindowNeedsInput(/* needsInput= */ false); @@ -228,6 +234,8 @@ public class CarKeyguardViewController extends OverlayViewController implements @Override public void startPreHideAnimation(Runnable finishRunnable) { + if (!mShowing) return; + mBouncer.startPreHideAnimation(finishRunnable); } @@ -260,12 +268,12 @@ public class CarKeyguardViewController extends OverlayViewController implements @Override public boolean isBouncerShowing() { - return mBouncer.isShowing(); + return mBouncer != null && mBouncer.isShowing(); } @Override public boolean bouncerIsOrWillBeShowing() { - return mBouncer.isShowing() || mBouncer.inTransit(); + return mBouncer != null && (mBouncer.isShowing() || mBouncer.inTransit()); } @Override