From 54d74e463f23a49a0fe424e9f0bec965f04bb648 Mon Sep 17 00:00:00 2001 From: Naomi Musgrave Date: Mon, 29 Nov 2021 13:09:50 +0000 Subject: [PATCH] Vertically center SCM-eligible on warm launch Currently, a landscape activity that is eligible for size compat mode is vertically centered on cold launch, and when put into size compat mode. Fix an issue introduced in a prior change, where vertical centering is not applied on warm launch. Bug: 207849112 Bug: 205682025 Test: atest com.android.server.wm.SizeCompatTests Change-Id: Id72e6efae49963ac9b6dd89cbc8c99e3a85b67f2 --- .../java/com/android/server/wm/ActivityRecord.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/services/core/java/com/android/server/wm/ActivityRecord.java b/services/core/java/com/android/server/wm/ActivityRecord.java index d97c845ef7c41..acb155bac5bc8 100644 --- a/services/core/java/com/android/server/wm/ActivityRecord.java +++ b/services/core/java/com/android/server/wm/ActivityRecord.java @@ -7922,9 +7922,17 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A // Above coordinates are in "@" space, now place "*" and "#" to screen space. final boolean fillContainer = resolvedBounds.equals(containingBounds); final int screenPosX = fillContainer ? containerBounds.left : containerAppBounds.left; - final int screenPosY = mSizeCompatBounds == null + // If the activity is not in size compat mode, calculate vertical centering + // from the container and resolved bounds. + // If the activity is in size compat mode, calculate vertical centering + // from the container and size compat bounds. + // The container bounds contain the parent bounds offset in the display, for + // example when an activity is in the lower split of split screen. + final int screenPosY = (mSizeCompatBounds == null ? (containerBounds.height() - resolvedBounds.height()) / 2 - : (containerBounds.height() - mSizeCompatBounds.height()) / 2; + : (containerBounds.height() - mSizeCompatBounds.height()) / 2) + + containerBounds.top; + if (screenPosX != 0 || screenPosY != 0) { if (mSizeCompatBounds != null) { mSizeCompatBounds.offset(screenPosX, screenPosY);