From 88d33ffa2c39e43bf9c290f535ac10ea545816d0 Mon Sep 17 00:00:00 2001 From: Winson Chung Date: Thu, 13 Aug 2020 18:48:27 -0700 Subject: [PATCH] Add some checks before using deferred-set controllers Bug: 164201104 Test: Manual Change-Id: Icfaaf661d7dd89a2e746dcfefb44731c275dcb06 --- .../systemui/navigationbar/NavigationBar.java | 32 +++++++++++++------ 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/navigationbar/NavigationBar.java b/packages/SystemUI/src/com/android/systemui/navigationbar/NavigationBar.java index 88400f0e0abe7..6c8a23ba96d19 100644 --- a/packages/SystemUI/src/com/android/systemui/navigationbar/NavigationBar.java +++ b/packages/SystemUI/src/com/android/systemui/navigationbar/NavigationBar.java @@ -860,10 +860,13 @@ public class NavigationBar implements View.OnAttachStateChangeListener, final int barMode = barMode(mTransientShown, mAppearance); mNavigationBarMode = barMode; checkNavBarModes(); - mAutoHideController.touchAutoHide(); - - mLightBarController.onNavigationBarAppearanceChanged(mAppearance, true /* nbModeChanged */, - barMode, false /* navbarColorManagedByIme */); + if (mAutoHideController != null) { + mAutoHideController.touchAutoHide(); + } + if (mLightBarController != null) { + mLightBarController.onNavigationBarAppearanceChanged(mAppearance, + true /* nbModeChanged */, barMode, false /* navbarColorManagedByIme */); + } } @Override @@ -880,8 +883,10 @@ public class NavigationBar implements View.OnAttachStateChangeListener, } nbModeChanged = updateBarMode(barMode(mTransientShown, appearance)); } - mLightBarController.onNavigationBarAppearanceChanged(appearance, nbModeChanged, - mNavigationBarMode, navbarColorManagedByIme); + if (mLightBarController != null) { + mLightBarController.onNavigationBarAppearanceChanged(appearance, nbModeChanged, + mNavigationBarMode, navbarColorManagedByIme); + } } @Override @@ -924,7 +929,7 @@ public class NavigationBar implements View.OnAttachStateChangeListener, mNavigationBarView.onTransientStateChanged(mTransientShown); } final int barMode = barMode(mTransientShown, mAppearance); - if (updateBarMode(barMode)) { + if (updateBarMode(barMode) && mLightBarController != null) { mLightBarController.onNavigationBarModeChanged(barMode); } } @@ -938,7 +943,9 @@ public class NavigationBar implements View.OnAttachStateChangeListener, } mNavigationBarMode = barMode; checkNavBarModes(); - mAutoHideController.touchAutoHide(); + if (mAutoHideController != null) { + mAutoHideController.touchAutoHide(); + } return true; } return false; @@ -1097,7 +1104,9 @@ public class NavigationBar implements View.OnAttachStateChangeListener, } private boolean onNavigationTouch(View v, MotionEvent event) { - mAutoHideController.checkUserAutoHide(event); + if (mAutoHideController != null) { + mAutoHideController.checkUserAutoHide(event); + } return false; } @@ -1356,7 +1365,10 @@ public class NavigationBar implements View.OnAttachStateChangeListener, public void setLightBarController(LightBarController lightBarController) { mLightBarController = lightBarController; - mLightBarController.setNavigationBar(mNavigationBarView.getLightTransitionsController()); + if (mLightBarController != null) { + mLightBarController.setNavigationBar( + mNavigationBarView.getLightTransitionsController()); + } } /** Sets {@link AutoHideController} to the navigation bar. */