Fixing a couple nav bar crashes
- Reset the rotation button controller callback when detaching the nav bar (the callback can otherwise be called back) - Only touch autohide if the controller is set (RotationButtonController update callback is set when initialized and not unset, so it too can callback into the nav bar view after it's been destroyed) - Add workaround for issue where content provider can still callback the observer after the observer has been unregistered, but the msg has been posted to the handler (filed b/198002034 to track fw fix) Bug: 194631201 Bug: 183051107 Bug: 197946101 Test: atest SystemUITests Change-Id: I520ca261b012d1d7f04ea8f732819e7eb1b4f77f
This commit is contained in:
@@ -422,6 +422,12 @@ public class NavigationBar implements View.OnAttachStateChangeListener,
|
|||||||
new Handler(Looper.getMainLooper())) {
|
new Handler(Looper.getMainLooper())) {
|
||||||
@Override
|
@Override
|
||||||
public void onChange(boolean selfChange, Uri uri) {
|
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();
|
updateAssistantEntrypoints();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -648,7 +654,7 @@ public class NavigationBar implements View.OnAttachStateChangeListener,
|
|||||||
if (mIsOnDefaultDisplay) {
|
if (mIsOnDefaultDisplay) {
|
||||||
final RotationButtonController rotationButtonController =
|
final RotationButtonController rotationButtonController =
|
||||||
mNavigationBarView.getRotationButtonController();
|
mNavigationBarView.getRotationButtonController();
|
||||||
rotationButtonController.addRotationCallback(mRotationWatcher);
|
rotationButtonController.setRotationCallback(mRotationWatcher);
|
||||||
|
|
||||||
// Reset user rotation pref to match that of the WindowManager if starting in locked
|
// 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.
|
// mode. This will automatically happen when switching from auto-rotate to locked mode.
|
||||||
@@ -687,6 +693,9 @@ public class NavigationBar implements View.OnAttachStateChangeListener,
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onViewDetachedFromWindow(View v) {
|
public void onViewDetachedFromWindow(View v) {
|
||||||
|
final RotationButtonController rotationButtonController =
|
||||||
|
mNavigationBarView.getRotationButtonController();
|
||||||
|
rotationButtonController.setRotationCallback(null);
|
||||||
mNavigationBarView.getBarTransitions().destroy();
|
mNavigationBarView.getBarTransitions().destroy();
|
||||||
mNavigationBarView.getLightTransitionsController().destroy(mContext);
|
mNavigationBarView.getLightTransitionsController().destroy(mContext);
|
||||||
mOverviewProxyService.removeCallback(mOverviewProxyListener);
|
mOverviewProxyService.removeCallback(mOverviewProxyListener);
|
||||||
|
|||||||
@@ -279,7 +279,7 @@ public class NavigationBarView extends FrameLayout implements
|
|||||||
new RotationButtonUpdatesCallback() {
|
new RotationButtonUpdatesCallback() {
|
||||||
@Override
|
@Override
|
||||||
public void onVisibilityChanged(boolean visible) {
|
public void onVisibilityChanged(boolean visible) {
|
||||||
if (visible) {
|
if (visible && mAutoHideController != null) {
|
||||||
// If the button will actually become visible and the navbar is about
|
// If the button will actually become visible and the navbar is about
|
||||||
// to hide, tell the statusbar to keep it around for longer
|
// to hide, tell the statusbar to keep it around for longer
|
||||||
mAutoHideController.touchAutoHide();
|
mAutoHideController.touchAutoHide();
|
||||||
|
|||||||
@@ -183,7 +183,7 @@ public class RotationButtonController {
|
|||||||
TaskStackChangeListeners.getInstance().unregisterTaskStackListener(mTaskStackListener);
|
TaskStackChangeListeners.getInstance().unregisterTaskStackListener(mTaskStackListener);
|
||||||
}
|
}
|
||||||
|
|
||||||
void addRotationCallback(Consumer<Integer> watcher) {
|
void setRotationCallback(Consumer<Integer> watcher) {
|
||||||
mRotWatcherListener = watcher;
|
mRotWatcherListener = watcher;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user