diff --git a/packages/SystemUI/src/com/android/systemui/navigationbar/NavigationBar.java b/packages/SystemUI/src/com/android/systemui/navigationbar/NavigationBar.java index 2016215a66cbda105285eddbdc6d6b20e5aff698..4a67e94425106d33c930071934090996027aae15 100644 --- a/packages/SystemUI/src/com/android/systemui/navigationbar/NavigationBar.java +++ b/packages/SystemUI/src/com/android/systemui/navigationbar/NavigationBar.java @@ -597,6 +597,7 @@ public class NavigationBar implements View.OnAttachStateChangeListener, } public void destroyView() { + setAutoHideController(/* autoHideController */ null); mCommandQueue.removeCallback(this); mContext.getSystemService(WindowManager.class).removeViewImmediate( mNavigationBarView.getRootView()); @@ -919,6 +920,11 @@ public class NavigationBar implements View.OnAttachStateChangeListener, @Override public void onRotationProposal(final int rotation, boolean isValid) { + // The CommandQueue callbacks are added when the view is created to ensure we track other + // states, but until the view is attached (at the next traversal), the view's display is + // not valid. Just ignore the rotation in this case. + if (!mNavigationBarView.isAttachedToWindow()) return; + final int winRotation = mNavigationBarView.getDisplay().getRotation(); final boolean rotateSuggestionsDisabled = RotationButtonController .hasDisable2RotateSuggestionFlag(mDisabledFlags2); @@ -1484,7 +1490,7 @@ public class NavigationBar implements View.OnAttachStateChangeListener, } /** Sets {@link AutoHideController} to the navigation bar. */ - public void setAutoHideController(AutoHideController autoHideController) { + private void setAutoHideController(AutoHideController autoHideController) { mAutoHideController = autoHideController; if (mAutoHideController != null) { mAutoHideController.setNavigationBar(mAutoHideUiElement); diff --git a/packages/SystemUI/src/com/android/systemui/navigationbar/NavigationBarController.java b/packages/SystemUI/src/com/android/systemui/navigationbar/NavigationBarController.java index 458c50d9cb817be22ed43d6cb78e8ddfb5b99ad6..543004eecb8ed67b86078a4efc6ce3fdc1cbbfe6 100644 --- a/packages/SystemUI/src/com/android/systemui/navigationbar/NavigationBarController.java +++ b/packages/SystemUI/src/com/android/systemui/navigationbar/NavigationBarController.java @@ -402,7 +402,6 @@ public class NavigationBarController implements Callbacks, void removeNavigationBar(int displayId) { NavigationBar navBar = mNavigationBars.get(displayId); if (navBar != null) { - navBar.setAutoHideController(/* autoHideController */ null); navBar.destroyView(); mNavigationBars.remove(displayId); }