From 972bbd9938145d9801239b5ea99cf0f47c6f3220 Mon Sep 17 00:00:00 2001 From: Garfield Tan Date: Wed, 25 Mar 2020 18:28:12 -0700 Subject: [PATCH] Remove insets before calculating bounds Bug: 152366979 Test: atest ActivityRecordTests#ignoreRequestedOrientationInFreeformWindows on landscape device with bottom inset Test: atest ActivityRecordTests#ignoreRequestedOrientationInSplitWindows on landscape device with bottom inset Change-Id: Ia5dc2260b688fead9f136574dcbaf093eb12c9db --- .../server/wm/ActivityRecordTests.java | 23 ++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/services/tests/wmtests/src/com/android/server/wm/ActivityRecordTests.java b/services/tests/wmtests/src/com/android/server/wm/ActivityRecordTests.java index 9e874211fcb39..d45f37bcf77bb 100644 --- a/services/tests/wmtests/src/com/android/server/wm/ActivityRecordTests.java +++ b/services/tests/wmtests/src/com/android/server/wm/ActivityRecordTests.java @@ -82,6 +82,7 @@ import android.os.PersistableBundle; import android.platform.test.annotations.Presubmit; import android.util.MergedConfiguration; import android.util.MutableBoolean; +import android.view.DisplayInfo; import android.view.IRemoteAnimationFinishedCallback; import android.view.IRemoteAnimationRunner.Stub; import android.view.RemoteAnimationAdapter; @@ -399,6 +400,16 @@ public class ActivityRecordTests extends ActivityTestsBase { mStack.setWindowingMode(WindowConfiguration.WINDOWING_MODE_FREEFORM); final Rect stableRect = new Rect(); mStack.getDisplay().mDisplayContent.getStableRect(stableRect); + + // Carve out non-decor insets from stableRect + final Rect insets = new Rect(); + final DisplayInfo displayInfo = mStack.getDisplay().getDisplayInfo(); + final DisplayPolicy policy = mStack.getDisplay().getDisplayPolicy(); + policy.getNonDecorInsetsLw(displayInfo.rotation, displayInfo.logicalWidth, + displayInfo.logicalHeight, displayInfo.displayCutout, insets); + policy.convertNonDecorInsetsToStableInsets(insets, displayInfo.rotation); + Task.intersectWithInsetsIfFits(stableRect, stableRect, insets); + final boolean isScreenPortrait = stableRect.width() <= stableRect.height(); final Rect bounds = new Rect(stableRect); if (isScreenPortrait) { @@ -427,7 +438,17 @@ public class ActivityRecordTests extends ActivityTestsBase { public void ignoreRequestedOrientationInSplitWindows() { mStack.setWindowingMode(WindowConfiguration.WINDOWING_MODE_SPLIT_SCREEN_PRIMARY); final Rect stableRect = new Rect(); - mStack.getDisplay().mDisplayContent.getStableRect(stableRect); + mStack.getDisplay().getStableRect(stableRect); + + // Carve out non-decor insets from stableRect + final Rect insets = new Rect(); + final DisplayInfo displayInfo = mStack.getDisplay().getDisplayInfo(); + final DisplayPolicy policy = mStack.getDisplay().getDisplayPolicy(); + policy.getNonDecorInsetsLw(displayInfo.rotation, displayInfo.logicalWidth, + displayInfo.logicalHeight, displayInfo.displayCutout, insets); + policy.convertNonDecorInsetsToStableInsets(insets, displayInfo.rotation); + Task.intersectWithInsetsIfFits(stableRect, stableRect, insets); + final boolean isScreenPortrait = stableRect.width() <= stableRect.height(); final Rect bounds = new Rect(stableRect); if (isScreenPortrait) {