Fixing a couple nav bar crashes am: a7c9bec46c

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/15744882

Change-Id: I65dd5d2bb51a68277b10e643bbb62270e82ab0e7
This commit is contained in:
Winson Chung
2021-09-02 22:43:46 +00:00
committed by Automerger Merge Worker
3 changed files with 12 additions and 3 deletions

View File

@@ -422,6 +422,12 @@ public class NavigationBar implements View.OnAttachStateChangeListener,
new Handler(Looper.getMainLooper())) {
@Override
public void onChange(boolean selfChange, Uri uri) {
// TODO(b/198002034): Content observers currently can still be called back after being
// unregistered, and in this case we can ignore the change if the nav bar has been
// destroyed already
if (mNavigationBarView == null) {
return;
}
updateAssistantEntrypoints();
}
};
@@ -648,7 +654,7 @@ public class NavigationBar implements View.OnAttachStateChangeListener,
if (mIsOnDefaultDisplay) {
final RotationButtonController rotationButtonController =
mNavigationBarView.getRotationButtonController();
rotationButtonController.addRotationCallback(mRotationWatcher);
rotationButtonController.setRotationCallback(mRotationWatcher);
// Reset user rotation pref to match that of the WindowManager if starting in locked
// mode. This will automatically happen when switching from auto-rotate to locked mode.
@@ -687,6 +693,9 @@ public class NavigationBar implements View.OnAttachStateChangeListener,
@Override
public void onViewDetachedFromWindow(View v) {
final RotationButtonController rotationButtonController =
mNavigationBarView.getRotationButtonController();
rotationButtonController.setRotationCallback(null);
mNavigationBarView.getBarTransitions().destroy();
mNavigationBarView.getLightTransitionsController().destroy(mContext);
mOverviewProxyService.removeCallback(mOverviewProxyListener);

View File

@@ -279,7 +279,7 @@ public class NavigationBarView extends FrameLayout implements
new RotationButtonUpdatesCallback() {
@Override
public void onVisibilityChanged(boolean visible) {
if (visible) {
if (visible && mAutoHideController != null) {
// If the button will actually become visible and the navbar is about
// to hide, tell the statusbar to keep it around for longer
mAutoHideController.touchAutoHide();

View File

@@ -183,7 +183,7 @@ public class RotationButtonController {
TaskStackChangeListeners.getInstance().unregisterTaskStackListener(mTaskStackListener);
}
void addRotationCallback(Consumer<Integer> watcher) {
void setRotationCallback(Consumer<Integer> watcher) {
mRotWatcherListener = watcher;
}