Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a06e04bc authored by Winson Chung's avatar Winson Chung
Browse files

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
parent 42e3933e
Loading
Loading
Loading
Loading
+5 −3
Original line number Diff line number Diff line
@@ -529,16 +529,17 @@ 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);
            if (mNavigationBarView != null) {
                mNavigationBarView.setWindowVisible(isNavBarWindowVisible());
            }
        }
    }

    @Override
    public void onRotationProposal(final int rotation, boolean isValid) {
@@ -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);