Merge "Set app space position to app configuration" into tm-qpr-dev am: 57ca5ef8b1
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/22069245 Change-Id: Ic2845f8a9e70dddad85d82af905fca1988a21c79 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -8309,6 +8309,10 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
|
|||||||
* requested in the config or via an ADB command. For more context see {@link
|
* requested in the config or via an ADB command. For more context see {@link
|
||||||
* LetterboxUiController#getHorizontalPositionMultiplier(Configuration)} and
|
* LetterboxUiController#getHorizontalPositionMultiplier(Configuration)} and
|
||||||
* {@link LetterboxUiController#getVerticalPositionMultiplier(Configuration)}
|
* {@link LetterboxUiController#getVerticalPositionMultiplier(Configuration)}
|
||||||
|
* <p>
|
||||||
|
* Note that this is the final step that can change the resolved bounds. After this method
|
||||||
|
* is called, the position of the bounds will be moved to app space as sandboxing if the
|
||||||
|
* activity has a size compat scale.
|
||||||
*/
|
*/
|
||||||
private void updateResolvedBoundsPosition(Configuration newParentConfiguration) {
|
private void updateResolvedBoundsPosition(Configuration newParentConfiguration) {
|
||||||
final Configuration resolvedConfig = getResolvedOverrideConfiguration();
|
final Configuration resolvedConfig = getResolvedOverrideConfiguration();
|
||||||
@@ -8370,6 +8374,18 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
|
|||||||
|
|
||||||
// Since bounds has changed, the configuration needs to be computed accordingly.
|
// Since bounds has changed, the configuration needs to be computed accordingly.
|
||||||
getTaskFragment().computeConfigResourceOverrides(resolvedConfig, newParentConfiguration);
|
getTaskFragment().computeConfigResourceOverrides(resolvedConfig, newParentConfiguration);
|
||||||
|
|
||||||
|
// The position of configuration bounds were calculated in screen space because that is
|
||||||
|
// easier to resolve the relative position in parent container. However, if the activity is
|
||||||
|
// scaled, the position should follow the scale because the configuration will be sent to
|
||||||
|
// the client which is expected to be in a scaled environment.
|
||||||
|
if (mSizeCompatScale != 1f) {
|
||||||
|
final int screenPosX = resolvedBounds.left;
|
||||||
|
final int screenPosY = resolvedBounds.top;
|
||||||
|
final int dx = (int) (screenPosX / mSizeCompatScale + 0.5f) - screenPosX;
|
||||||
|
final int dy = (int) (screenPosY / mSizeCompatScale + 0.5f) - screenPosY;
|
||||||
|
offsetBounds(resolvedConfig, dx, dy);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void recomputeConfiguration() {
|
void recomputeConfiguration() {
|
||||||
|
|||||||
@@ -574,11 +574,11 @@ public class SizeCompatTests extends WindowTestsBase {
|
|||||||
// The scale is 2000/2500=0.8. The horizontal centered offset is (1000-(1000*0.8))/2=100.
|
// The scale is 2000/2500=0.8. The horizontal centered offset is (1000-(1000*0.8))/2=100.
|
||||||
final float scale = (float) display.mBaseDisplayHeight / currentBounds.height();
|
final float scale = (float) display.mBaseDisplayHeight / currentBounds.height();
|
||||||
final int offsetX = (int) (display.mBaseDisplayWidth - (origBounds.width() * scale)) / 2;
|
final int offsetX = (int) (display.mBaseDisplayWidth - (origBounds.width() * scale)) / 2;
|
||||||
assertEquals(offsetX, currentBounds.left);
|
final int screenX = mActivity.getBounds().left;
|
||||||
|
assertEquals(offsetX, screenX);
|
||||||
|
|
||||||
// The position of configuration bounds should be the same as compat bounds.
|
// The position of configuration bounds should be in app space.
|
||||||
assertEquals(mActivity.getBounds().left, currentBounds.left);
|
assertEquals(screenX, (int) (currentBounds.left * scale + 0.5f));
|
||||||
assertEquals(mActivity.getBounds().top, currentBounds.top);
|
|
||||||
// Activity is sandboxed to the offset size compat bounds.
|
// Activity is sandboxed to the offset size compat bounds.
|
||||||
assertActivityMaxBoundsSandboxed();
|
assertActivityMaxBoundsSandboxed();
|
||||||
|
|
||||||
@@ -608,7 +608,7 @@ public class SizeCompatTests extends WindowTestsBase {
|
|||||||
// The size should still be in portrait [100, 0 - 1100, 2500] = 1000x2500.
|
// The size should still be in portrait [100, 0 - 1100, 2500] = 1000x2500.
|
||||||
assertEquals(origBounds.width(), currentBounds.width());
|
assertEquals(origBounds.width(), currentBounds.width());
|
||||||
assertEquals(origBounds.height(), currentBounds.height());
|
assertEquals(origBounds.height(), currentBounds.height());
|
||||||
assertEquals(offsetX, currentBounds.left);
|
assertEquals(offsetX, mActivity.getBounds().left);
|
||||||
assertScaled();
|
assertScaled();
|
||||||
// Activity is sandboxed due to size compat mode.
|
// Activity is sandboxed due to size compat mode.
|
||||||
assertActivityMaxBoundsSandboxed();
|
assertActivityMaxBoundsSandboxed();
|
||||||
@@ -771,9 +771,11 @@ public class SizeCompatTests extends WindowTestsBase {
|
|||||||
assertEquals(origAppBounds.height(), appBounds.height());
|
assertEquals(origAppBounds.height(), appBounds.height());
|
||||||
// The activity is 1000x1400 and the display is 2500x1000.
|
// The activity is 1000x1400 and the display is 2500x1000.
|
||||||
assertScaled();
|
assertScaled();
|
||||||
// The position in configuration should be global coordinates.
|
final float scale = mActivity.getCompatScale();
|
||||||
assertEquals(mActivity.getBounds().left, currentBounds.left);
|
// The position in configuration should be in app coordinates.
|
||||||
assertEquals(mActivity.getBounds().top, currentBounds.top);
|
final Rect screenBounds = mActivity.getBounds();
|
||||||
|
assertEquals(screenBounds.left, (int) (currentBounds.left * scale + 0.5f));
|
||||||
|
assertEquals(screenBounds.top, (int) (currentBounds.top * scale + 0.5f));
|
||||||
|
|
||||||
// Activity max bounds are sandboxed due to size compat mode.
|
// Activity max bounds are sandboxed due to size compat mode.
|
||||||
assertActivityMaxBoundsSandboxed();
|
assertActivityMaxBoundsSandboxed();
|
||||||
|
|||||||
Reference in New Issue
Block a user