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
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user