diff options
| author | 2023-07-21 07:28:52 +0000 | |
|---|---|---|
| committer | 2023-07-27 05:24:33 +0000 | |
| commit | a102c85e21390afdbb05dcf6963e26acca9d6bf2 (patch) | |
| tree | 994e67ef7ffc673d7e107545bcb1a62e550a8e9b | |
| parent | 3490e6fb8fe5282134aa542f2cde6d66aafbbea4 (diff) | |
Polish splash screen window from large to small activity.
The splash screen window will be cropped by letterbox controller when
transfer it from a large activity to smaller activity.
Another similar case can happen when app calls
Activity#setRequestedOrientation, which changes the activity's bounds
and modify the window's surface position.
By reuse the mAssociatedTask to reparent the splash screen window to
task, we can fix the splash screen window on task so it won't resize
from transfer starting window anymore, also skip crop or offset the
window if it is associated to task.
Also polish a case that starting window can suddenly gone if the launch
activity isn't visible when remove starting window, it should be
onScreen if the associated task is visible.
Bug: 292187844
Bug: 278931413
Test: launch test app, verify the splash screen won't resize anymore
during transfer across trampoline activities. Also verify splash screen
window won't resize when activity request orientation.
Change-Id: I2fc540191e4db5afa4eafdbc71ab29bd3570d2d4
3 files changed, 18 insertions, 3 deletions
diff --git a/services/core/java/com/android/server/wm/ActivityRecord.java b/services/core/java/com/android/server/wm/ActivityRecord.java index e93f35802953..2b6193ddc43d 100644 --- a/services/core/java/com/android/server/wm/ActivityRecord.java +++ b/services/core/java/com/android/server/wm/ActivityRecord.java @@ -2676,7 +2676,9 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A private boolean transferSplashScreenIfNeeded() { if (finishing || !mHandleExitSplashScreen || mStartingSurface == null || mStartingWindow == null - || mTransferringSplashScreenState == TRANSFER_SPLASH_SCREEN_FINISH) { + || mTransferringSplashScreenState == TRANSFER_SPLASH_SCREEN_FINISH + // skip copy splash screen to client if it was resized + || (mStartingData != null && mStartingData.mResizedFromTransfer)) { return false; } if (isTransferringSplashScreen()) { diff --git a/services/core/java/com/android/server/wm/StartingData.java b/services/core/java/com/android/server/wm/StartingData.java index cff86add7efc..2b22d75693fe 100644 --- a/services/core/java/com/android/server/wm/StartingData.java +++ b/services/core/java/com/android/server/wm/StartingData.java @@ -38,6 +38,10 @@ public abstract class StartingData { */ Task mAssociatedTask; + + /** Whether the starting window is resized from transfer across activities. */ + boolean mResizedFromTransfer; + /** Whether the starting window is drawn. */ boolean mIsDisplayed; diff --git a/services/core/java/com/android/server/wm/WindowState.java b/services/core/java/com/android/server/wm/WindowState.java index 0d4c2d631b2c..dadb198d5a61 100644 --- a/services/core/java/com/android/server/wm/WindowState.java +++ b/services/core/java/com/android/server/wm/WindowState.java @@ -1935,7 +1935,9 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP } final ActivityRecord atoken = mActivityRecord; if (atoken != null) { - return ((!isParentWindowHidden() && atoken.isVisible()) + final boolean isVisible = isStartingWindowAssociatedToTask() + ? mStartingData.mAssociatedTask.isVisible() : atoken.isVisible(); + return ((!isParentWindowHidden() && isVisible) || isAnimationRunningSelfOrParent()); } final WallpaperWindowToken wtoken = mToken.asWallpaperToken(); @@ -2330,6 +2332,13 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP // IME surface association. (e.g. Attach IME surface on the display instead of the // app when the app bounds being letterboxed.) mDisplayContent.updateImeControlTarget(isImeLayeringTarget() /* updateImeParent */); + // Fix the starting window to task when Activity has changed. + if (mStartingData != null && mStartingData.mAssociatedTask == null + && !mTempConfiguration.windowConfiguration.getBounds().equals(getBounds())) { + mStartingData.mResizedFromTransfer = true; + // Lock the starting window to task, so it won't resize from transfer anymore. + mActivityRecord.associateStartingWindowWithTaskIfNeeded(); + } } } @@ -3902,7 +3911,7 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP * LetterboxUiController#shouldShowLetterboxUi} for more context. */ boolean areAppWindowBoundsLetterboxed() { - return mActivityRecord != null + return mActivityRecord != null && !isStartingWindowAssociatedToTask() && (mActivityRecord.areBoundsLetterboxed() || isLetterboxedForDisplayCutout()); } |