Ensure insets state for dispatch is processed by policy
Otherwise the visibility of transient state doesn't take effect if there is a fixed rotation insets state. Then the client side may not aware visibility change to update alpha of insets leash. Bug: 160458371 Test: atest DisplayPolicyLayoutTests#testFixedRotationInsetsSourceFrame InsetsStateControllerTest#testTransientVisibilityOfFixedRotationState Change-Id: Icecb25f64e983b163f169c191a9f0b15ac1b3086 Merged-In: Icecb25f64e983b163f169c191a9f0b15ac1b3086
This commit is contained in:
@@ -107,6 +107,10 @@ class InsetsStateController {
|
||||
* @return The state stripped of the necessary information.
|
||||
*/
|
||||
InsetsState getInsetsForDispatch(@NonNull WindowState target) {
|
||||
final InsetsState rotatedState = target.mToken.getFixedRotationTransformInsetsState();
|
||||
if (rotatedState != null) {
|
||||
return rotatedState;
|
||||
}
|
||||
final InsetsSourceProvider provider = target.getControllableInsetProvider();
|
||||
final @InternalInsetsType int type = provider != null
|
||||
? provider.getSource().getType() : ITYPE_INVALID;
|
||||
|
||||
@@ -1526,10 +1526,6 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
|
||||
}
|
||||
|
||||
InsetsState getInsetsState() {
|
||||
final InsetsState insetsState = mToken.getFixedRotationTransformInsetsState();
|
||||
if (insetsState != null) {
|
||||
return insetsState;
|
||||
}
|
||||
return getDisplayContent().getInsetsPolicy().getInsetsForDispatch(this);
|
||||
}
|
||||
|
||||
|
||||
@@ -52,10 +52,13 @@ import static android.view.WindowManagerPolicyConstants.ALT_BAR_LEFT;
|
||||
import static android.view.WindowManagerPolicyConstants.ALT_BAR_RIGHT;
|
||||
import static android.view.WindowManagerPolicyConstants.ALT_BAR_TOP;
|
||||
|
||||
import static com.android.dx.mockito.inline.extended.ExtendedMockito.doReturn;
|
||||
|
||||
import static org.hamcrest.Matchers.is;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotEquals;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.Mockito.doNothing;
|
||||
import static org.mockito.Mockito.spy;
|
||||
import static org.testng.Assert.expectThrows;
|
||||
@@ -926,6 +929,25 @@ public class DisplayPolicyLayoutTests extends DisplayPolicyTestsBase {
|
||||
new ToStringComparatorWrapper<>(simulatedInsetsState));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFixedRotationInsetsSourceFrame() {
|
||||
final DisplayInfo info = mDisplayContent.getDisplayInfo();
|
||||
info.rotation = mFrames.mRotation;
|
||||
mDisplayContent.mBaseDisplayHeight = info.logicalHeight = mFrames.mDisplayHeight;
|
||||
mDisplayContent.mBaseDisplayWidth = info.logicalWidth = mFrames.mDisplayWidth;
|
||||
mDisplayContent.getInsetsStateController().onPostLayout();
|
||||
mDisplayPolicy.beginLayoutLw(mFrames, mDisplayContent.getConfiguration().uiMode);
|
||||
doReturn((mDisplayContent.getRotation() + 1) % 4).when(mDisplayContent)
|
||||
.rotationForActivityInDifferentOrientation(eq(mWindow.mActivityRecord));
|
||||
final Rect frame = mWindow.getInsetsState().getSource(ITYPE_STATUS_BAR).getFrame();
|
||||
doReturn(mDisplayPolicy).when(mDisplayContent).getDisplayPolicy();
|
||||
mDisplayContent.rotateInDifferentOrientationIfNeeded(mWindow.mActivityRecord);
|
||||
final Rect rotatedFrame = mWindow.getInsetsState().getSource(ITYPE_STATUS_BAR).getFrame();
|
||||
|
||||
assertEquals(DISPLAY_WIDTH, frame.width());
|
||||
assertEquals(DISPLAY_HEIGHT, rotatedFrame.width());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testScreenDecorWindows() {
|
||||
final WindowState decorWindow = createWindow(null, TYPE_APPLICATION_OVERLAY, "decorWindow");
|
||||
|
||||
@@ -30,6 +30,9 @@ import static android.view.WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM;
|
||||
import static android.view.WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE;
|
||||
import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION;
|
||||
|
||||
import static com.android.dx.mockito.inline.extended.ExtendedMockito.doReturn;
|
||||
import static com.android.dx.mockito.inline.extended.ExtendedMockito.spyOn;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
@@ -329,6 +332,26 @@ public class InsetsStateControllerTest extends WindowTestsBase {
|
||||
assertNull(getController().getControlsForDispatch(app));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTransientVisibilityOfFixedRotationState() {
|
||||
final WindowState statusBar = createWindow(null, TYPE_APPLICATION, "statusBar");
|
||||
final WindowState app = createWindow(null, TYPE_APPLICATION, "app");
|
||||
final InsetsSourceProvider provider = getController().getSourceProvider(ITYPE_STATUS_BAR);
|
||||
provider.setWindow(statusBar, null, null);
|
||||
|
||||
final InsetsState rotatedState = new InsetsState(app.getInsetsState(),
|
||||
true /* copySources */);
|
||||
spyOn(app.mToken);
|
||||
doReturn(rotatedState).when(app.mToken).getFixedRotationTransformInsetsState();
|
||||
assertTrue(rotatedState.getSource(ITYPE_STATUS_BAR).isVisible());
|
||||
|
||||
provider.getSource().setVisible(false);
|
||||
mDisplayContent.getInsetsPolicy().showTransient(new int[] { ITYPE_STATUS_BAR });
|
||||
|
||||
assertTrue(mDisplayContent.getInsetsPolicy().isTransient(ITYPE_STATUS_BAR));
|
||||
assertFalse(app.getInsetsState().getSource(ITYPE_STATUS_BAR).isVisible());
|
||||
}
|
||||
|
||||
private InsetsStateController getController() {
|
||||
return mDisplayContent.getInsetsStateController();
|
||||
}
|
||||
|
||||
@@ -568,6 +568,8 @@ public class SizeCompatTests extends ActivityTestsBase {
|
||||
private static WindowState addWindowToActivity(ActivityRecord activity) {
|
||||
final WindowManager.LayoutParams params = new WindowManager.LayoutParams();
|
||||
params.type = WindowManager.LayoutParams.TYPE_BASE_APPLICATION;
|
||||
params.setFitInsetsSides(0);
|
||||
params.setFitInsetsTypes(0);
|
||||
final WindowTestUtils.TestWindowState w = new WindowTestUtils.TestWindowState(
|
||||
activity.mWmService, mock(Session.class), new TestIWindow(), params, activity);
|
||||
WindowTestsBase.makeWindowVisible(w);
|
||||
|
||||
Reference in New Issue
Block a user