From bc27dc39217a44b937a0877c9a86283405dc6142 Mon Sep 17 00:00:00 2001 From: Hiroki Sato Date: Thu, 15 Sep 2022 12:38:38 +0900 Subject: [PATCH] Keep frames when providing insets to freeform windows A previous CL [1] removed all frames and insets except for caption and ime provided to freeform windows. However, some frames should be kept. For example, according to WindowInsets#getPrivacyIndicatorBounds, this value should not be null when there's a privacy indicator. This change adds back frames for freeform windows. [1] Ife41a37082a65db50c7bb5b75690db5bc3cb0bd2 Bug: 226707036 Test: android.server.wm.PrivacyIndicatorBoundsTests Change-Id: I9a7aafdfbbb9490ba646dc113b135515781cdb82 --- .../java/com/android/server/wm/InsetsPolicy.java | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/services/core/java/com/android/server/wm/InsetsPolicy.java b/services/core/java/com/android/server/wm/InsetsPolicy.java index f3bd1a15cc949..2de8faf8b0861 100644 --- a/services/core/java/com/android/server/wm/InsetsPolicy.java +++ b/services/core/java/com/android/server/wm/InsetsPolicy.java @@ -64,6 +64,7 @@ import android.view.InsetsState.InternalInsetsType; import android.view.InternalInsetsAnimationController; import android.view.SurfaceControl; import android.view.SyncRtSurfaceTransactionApplier; +import android.view.WindowInsets; import android.view.WindowInsets.Type; import android.view.WindowInsetsAnimation; import android.view.WindowInsetsAnimation.Bounds; @@ -398,16 +399,13 @@ class InsetsPolicy { if (WindowConfiguration.isFloating(windowingMode) || (windowingMode == WINDOWING_MODE_MULTI_WINDOW && isAlwaysOnTop)) { + // Keep frames, caption, and IME. + int types = WindowInsets.Type.captionBar(); + if (windowingMode != WINDOWING_MODE_PINNED) { + types |= WindowInsets.Type.ime(); + } InsetsState newState = new InsetsState(); - - // Only caption and IME are needed. - if (state.peekSource(ITYPE_CAPTION_BAR) != null) { - newState.addSource(state.peekSource(ITYPE_CAPTION_BAR)); - } - if (windowingMode != WINDOWING_MODE_PINNED && state.peekSource(ITYPE_IME) != null) { - newState.addSource(state.peekSource(ITYPE_IME)); - } - + newState.set(state, types); state = newState; stateCopied = true; }