summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Winson Chung <winsonc@google.com> 2020-03-04 13:11:18 -0800
committer Winson Chung <winsonc@google.com> 2020-03-04 13:12:33 -0800
commita06e04bcd42734f8e00d536b9e4b689eb82b5f6c (patch)
treef88551a3aef4591f879d67a590921e545e0657b9
parent42e3933e546a16dd3b28e1fcaf171111f05cb407 (diff)
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
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarFragment.java8
1 files 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);