Merge "Use correct windowingMode when computing override config" into pi-dev
This commit is contained in:
@@ -495,7 +495,15 @@ public class WindowConfiguration implements Parcelable, Comparable<WindowConfigu
|
||||
* @hide
|
||||
*/
|
||||
public boolean tasksAreFloating() {
|
||||
return mWindowingMode == WINDOWING_MODE_FREEFORM || mWindowingMode == WINDOWING_MODE_PINNED;
|
||||
return isFloating(mWindowingMode);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the windowingMode represents a floating window.
|
||||
* @hide
|
||||
*/
|
||||
public static boolean isFloating(int windowingMode) {
|
||||
return windowingMode == WINDOWING_MODE_FREEFORM || windowingMode == WINDOWING_MODE_PINNED;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1820,7 +1820,7 @@ class TaskRecord extends ConfigurationContainer implements TaskWindowContainerLi
|
||||
final StackWindowController stackController = mStack.getWindowContainerController();
|
||||
stackController.adjustConfigurationForBounds(bounds, insetBounds,
|
||||
mTmpNonDecorBounds, mTmpStableBounds, overrideWidth, overrideHeight, density,
|
||||
config, parentConfig);
|
||||
config, parentConfig, getWindowingMode());
|
||||
} else {
|
||||
throw new IllegalArgumentException("Expected stack when calculating override config");
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
package com.android.server.wm;
|
||||
|
||||
import android.app.WindowConfiguration;
|
||||
import android.content.res.Configuration;
|
||||
import android.graphics.Rect;
|
||||
import android.os.Handler;
|
||||
@@ -244,12 +245,15 @@ public class StackWindowController
|
||||
}
|
||||
|
||||
/**
|
||||
* Adjusts the screen size in dp's for the {@param config} for the given params.
|
||||
* Adjusts the screen size in dp's for the {@param config} for the given params. The provided
|
||||
* params represent the desired state of a configuration change. Since this utility is used
|
||||
* before mContainer has been updated, any relevant properties (like {@param windowingMode})
|
||||
* need to be passed in.
|
||||
*/
|
||||
public void adjustConfigurationForBounds(Rect bounds, Rect insetBounds,
|
||||
Rect nonDecorBounds, Rect stableBounds, boolean overrideWidth,
|
||||
boolean overrideHeight, float density, Configuration config,
|
||||
Configuration parentConfig) {
|
||||
Configuration parentConfig, int windowingMode) {
|
||||
synchronized (mWindowMap) {
|
||||
final TaskStack stack = mContainer;
|
||||
final DisplayContent displayContent = stack.getDisplayContent();
|
||||
@@ -272,10 +276,10 @@ public class StackWindowController
|
||||
config.windowConfiguration.setAppBounds(!bounds.isEmpty() ? bounds : null);
|
||||
boolean intersectParentBounds = false;
|
||||
|
||||
if (stack.getWindowConfiguration().tasksAreFloating()) {
|
||||
if (WindowConfiguration.isFloating(windowingMode)) {
|
||||
// Floating tasks should not be resized to the screen's bounds.
|
||||
|
||||
if (stack.inPinnedWindowingMode()
|
||||
if (windowingMode == WindowConfiguration.WINDOWING_MODE_PINNED
|
||||
&& bounds.width() == mTmpDisplayBounds.width()
|
||||
&& bounds.height() == mTmpDisplayBounds.height()) {
|
||||
// If the bounds we are animating is the same as the fullscreen stack
|
||||
@@ -316,7 +320,7 @@ public class StackWindowController
|
||||
config.screenWidthDp = width;
|
||||
config.screenHeightDp = height;
|
||||
config.smallestScreenWidthDp = getSmallestWidthForTaskBounds(
|
||||
insetBounds != null ? insetBounds : bounds, density);
|
||||
insetBounds != null ? insetBounds : bounds, density, windowingMode);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -338,11 +342,12 @@ public class StackWindowController
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculates the smallest width for a task given the {@param bounds}.
|
||||
* Calculates the smallest width for a task given the target {@param bounds} and
|
||||
* {@param windowingMode}. Avoid using values from mContainer since they can be out-of-date.
|
||||
*
|
||||
* @return the smallest width to be used in the Configuration, in dips
|
||||
*/
|
||||
private int getSmallestWidthForTaskBounds(Rect bounds, float density) {
|
||||
private int getSmallestWidthForTaskBounds(Rect bounds, float density, int windowingMode) {
|
||||
final DisplayContent displayContent = mContainer.getDisplayContent();
|
||||
final DisplayInfo displayInfo = displayContent.getDisplayInfo();
|
||||
|
||||
@@ -350,7 +355,7 @@ public class StackWindowController
|
||||
bounds.height() == displayInfo.logicalHeight)) {
|
||||
// If the bounds are fullscreen, return the value of the fullscreen configuration
|
||||
return displayContent.getConfiguration().smallestScreenWidthDp;
|
||||
} else if (mContainer.getWindowConfiguration().tasksAreFloating()) {
|
||||
} else if (WindowConfiguration.isFloating(windowingMode)) {
|
||||
// For floating tasks, calculate the smallest width from the bounds of the task
|
||||
return (int) (Math.min(bounds.width(), bounds.height()) / density);
|
||||
} else {
|
||||
|
||||
@@ -208,7 +208,8 @@ public class WindowConfigurationTests extends WindowTestsBase {
|
||||
final WindowConfiguration winConfig = config.windowConfiguration;
|
||||
stackController.adjustConfigurationForBounds(bounds, null /*insetBounds*/,
|
||||
new Rect() /*nonDecorBounds*/, new Rect() /*stableBounds*/, false /*overrideWidth*/,
|
||||
false /*overrideHeight*/, mDisplayInfo.logicalDensityDpi, config, parentConfig);
|
||||
false /*overrideHeight*/, mDisplayInfo.logicalDensityDpi, config, parentConfig,
|
||||
windowingMode);
|
||||
// Assert that both expected and actual are null or are equal to each other
|
||||
|
||||
assertEquals(expectedConfigBounds, winConfig.getAppBounds());
|
||||
|
||||
@@ -34,6 +34,7 @@ import static com.android.server.wm.WindowContainer.POSITION_TOP;
|
||||
import static org.mockito.Mockito.any;
|
||||
import static org.mockito.Mockito.anyBoolean;
|
||||
import static org.mockito.Mockito.anyFloat;
|
||||
import static org.mockito.Mockito.anyInt;
|
||||
import static org.mockito.Mockito.doAnswer;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
@@ -72,7 +73,7 @@ public class WindowTestUtils {
|
||||
config.windowConfiguration.setBounds(bounds);
|
||||
return null;
|
||||
}).when(controller).adjustConfigurationForBounds(any(), any(), any(), any(),
|
||||
anyBoolean(), anyBoolean(), anyFloat(), any(), any());
|
||||
anyBoolean(), anyBoolean(), anyFloat(), any(), any(), anyInt());
|
||||
|
||||
return controller;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user