Merge "Make the visibility of rotated insets up-to-date"

This commit is contained in:
Riddle Hsu
2020-12-01 15:19:11 +00:00
committed by Android (Google) Code Review
3 changed files with 34 additions and 4 deletions

View File

@@ -1679,6 +1679,28 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp
}
}
void notifyInsetsChanged(Consumer<WindowState> dispatchInsetsChanged) {
if (mFixedRotationLaunchingApp != null) {
// The insets state of fixed rotation app is a rotated copy. Make sure the visibilities
// of insets sources are consistent with the latest state.
final InsetsState rotatedState =
mFixedRotationLaunchingApp.getFixedRotationTransformInsetsState();
if (rotatedState != null) {
final InsetsState state = mInsetsStateController.getRawInsetsState();
for (int i = 0; i < InsetsState.SIZE; i++) {
final InsetsSource source = state.peekSource(i);
if (source != null) {
rotatedState.setSourceVisible(i, source.isVisible());
}
}
}
}
forAllWindows(dispatchInsetsChanged, true /* traverseTopToBottom */);
if (mRemoteInsetsControlTarget != null) {
mRemoteInsetsControlTarget.notifyInsetsChanged();
}
}
/**
* Update rotation of the display.
*

View File

@@ -496,10 +496,7 @@ class InsetsStateController {
}
void notifyInsetsChanged() {
mDisplayContent.forAllWindows(mDispatchInsetsChanged, true /* traverseTopToBottom */);
if (mDisplayContent.mRemoteInsetsControlTarget != null) {
mDisplayContent.mRemoteInsetsControlTarget.notifyInsetsChanged();
}
mDisplayContent.notifyInsetsChanged(mDispatchInsetsChanged);
}
void dump(String prefix, PrintWriter pw) {

View File

@@ -1202,6 +1202,17 @@ public class DisplayContentTests extends WindowTestsBase {
assertTrue(mNavBarWindow.getParent().isAnimating(WindowContainer.AnimationFlags.PARENTS,
ANIMATION_TYPE_FIXED_TRANSFORM));
// If the visibility of insets state is changed, the rotated state should be updated too.
final InsetsState rotatedState = app.getFixedRotationTransformInsetsState();
final InsetsState state = mDisplayContent.getInsetsStateController().getRawInsetsState();
assertEquals(state.getSource(ITYPE_STATUS_BAR).isVisible(),
rotatedState.getSource(ITYPE_STATUS_BAR).isVisible());
state.getSource(ITYPE_STATUS_BAR).setVisible(
!rotatedState.getSource(ITYPE_STATUS_BAR).isVisible());
mDisplayContent.getInsetsStateController().notifyInsetsChanged();
assertEquals(state.getSource(ITYPE_STATUS_BAR).isVisible(),
rotatedState.getSource(ITYPE_STATUS_BAR).isVisible());
final Rect outFrame = new Rect();
final Rect outInsets = new Rect();
final Rect outStableInsets = new Rect();