Merge "Restrict DisplayArea appBounds to the override bounds" into sc-dev

This commit is contained in:
Chris Li
2021-02-02 07:53:31 +00:00
committed by Android (Google) Code Review
3 changed files with 46 additions and 2 deletions

View File

@@ -461,6 +461,23 @@ public class DisplayArea<T extends WindowContainer> extends WindowContainer<T> {
}
}
@Override
void resolveOverrideConfiguration(Configuration newParentConfiguration) {
super.resolveOverrideConfiguration(newParentConfiguration);
final Configuration resolvedConfig = getResolvedOverrideConfiguration();
final Rect overrideBounds = resolvedConfig.windowConfiguration.getBounds();
final Rect overrideAppBounds = resolvedConfig.windowConfiguration.getAppBounds();
final Rect parentAppBounds = newParentConfiguration.windowConfiguration.getAppBounds();
// If there is no override of appBounds, restrict appBounds to the override bounds.
if (!overrideBounds.isEmpty() && (overrideAppBounds == null || overrideAppBounds.isEmpty())
&& parentAppBounds != null && !parentAppBounds.isEmpty()) {
final Rect appBounds = new Rect(overrideBounds);
appBounds.intersect(parentAppBounds);
resolvedConfig.windowConfiguration.setAppBounds(appBounds);
}
}
@Override
boolean isOrganized() {
return mOrganizer != null;

View File

@@ -16,8 +16,8 @@
package com.android.server.wm;
import static android.content.ActivityInfoProto.SCREEN_ORIENTATION_PORTRAIT;
import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE;
import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_PORTRAIT;
import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION;
import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_OVERLAY;
import static android.view.WindowManager.LayoutParams.TYPE_PRESENTATION;
@@ -50,6 +50,7 @@ import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyZeroInteractions;
import android.content.pm.ActivityInfo;
import android.content.res.Configuration;
import android.graphics.Rect;
import android.os.Binder;
import android.platform.test.annotations.Presubmit;
@@ -407,6 +408,32 @@ public class DisplayAreaTest extends WindowTestsBase {
childBounds1, windowToken.getMaxBounds());
}
@Test
public void testRestrictAppBoundsToOverrideBounds() {
final RootDisplayArea root =
new DisplayAreaPolicyBuilderTest.SurfacelessDisplayAreaRoot(mWm);
final DisplayArea<DisplayArea> da = new DisplayArea<>(mWm, ANY, "Test_DA");
root.addChild(da, POSITION_TOP);
final Rect displayBounds = new Rect(0, 0, 1800, 2800);
final Rect displayAppBounds = new Rect(0, 100, 1800, 2800);
final Rect daBounds = new Rect(0, 1400, 1800, 2800);
root.setBounds(displayBounds);
// DA inherit parent app bounds.
final Configuration displayConfig = new Configuration();
displayConfig.windowConfiguration.setAppBounds(displayAppBounds);
root.onRequestedOverrideConfigurationChanged(displayConfig);
assertEquals(displayAppBounds, da.getConfiguration().windowConfiguration.getAppBounds());
// Restrict DA appBounds to override Bounds
da.setBounds(daBounds);
final Rect expectedDaAppBounds = new Rect(daBounds);
expectedDaAppBounds.intersect(displayAppBounds);
assertEquals(expectedDaAppBounds, da.getConfiguration().windowConfiguration.getAppBounds());
}
@Test
public void testGetOrientation() {
final DisplayArea.Tokens area = new DisplayArea.Tokens(mWm, ABOVE_TASKS, "test");

View File

@@ -16,7 +16,7 @@
package com.android.server.wm;
import static android.content.ActivityInfoProto.SCREEN_ORIENTATION_LANDSCAPE;
import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE;
import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_PORTRAIT;
import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED;
import static android.content.res.Configuration.ORIENTATION_LANDSCAPE;