From a06e04bcd42734f8e00d536b9e4b689eb82b5f6c Mon Sep 17 00:00:00 2001 From: Winson Chung Date: Wed, 4 Mar 2020 13:11:18 -0800 Subject: Fix a couple small issues in nav bar fragment - Remove attached state change listener when the view is detached - Fix for hypothetical race, if the system calls setWindowState before the fragment view is created, we will drop the new window state and also not update the sysui state flags. Instead, always update the window state and only update the nav bar window visibility if it exists or when it is created (which is already being done). Bug: 147890990 Test: manual --- .../android/systemui/statusbar/phone/NavigationBarFragment.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarFragment.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarFragment.java index 02cf8ccbef8b..8feb116ee242 100644 --- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarFragment.java +++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarFragment.java @@ -529,14 +529,15 @@ public class NavigationBarFragment extends LifecycleFragment implements Callback public void setWindowState( int displayId, @WindowType int window, @WindowVisibleState int state) { if (displayId == mDisplayId - && mNavigationBarView != null && window == StatusBarManager.WINDOW_NAVIGATION_BAR && mNavigationBarWindowState != state) { mNavigationBarWindowState = state; + updateSystemUiStateFlags(-1); if (DEBUG_WINDOW_STATE) Log.d(TAG, "Navigation bar " + windowStateToString(state)); - updateSystemUiStateFlags(-1); - mNavigationBarView.setWindowVisible(isNavBarWindowVisible()); + if (mNavigationBarView != null) { + mNavigationBarView.setWindowVisible(isNavBarWindowVisible()); + } } } @@ -1212,6 +1213,7 @@ public class NavigationBarFragment extends LifecycleFragment implements Callback @Override public void onViewDetachedFromWindow(View v) { FragmentHostManager.removeAndDestroy(v); + navigationBarView.removeOnAttachStateChangeListener(this); } }); context.getSystemService(WindowManager.class).addView(navigationBarView, lp); -- cgit v1.2.3-59-g8ed1b