From 4eaf39219ba94606d08e6dc68eda8214978ab7b9 Mon Sep 17 00:00:00 2001 From: Tyler Lacey Date: Wed, 6 Apr 2022 13:41:11 +0000 Subject: [PATCH 1/2] When adding overlay to a task, emit an immediate inset update Test: Manual testing no longer reproduce b/227202029 Bug: 227202029 Change-Id: I73dd21e027c5fff66185f03d3ffd4e2f4b3f61fb --- data/etc/services.core.protolog.json | 6 ++++++ .../com/android/server/wm/WindowContainer.java | 17 ++++++++++++++++- .../android/server/wm/WindowManagerService.java | 2 +- 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/data/etc/services.core.protolog.json b/data/etc/services.core.protolog.json index 80b144acd991d..0bd01169f53f1 100644 --- a/data/etc/services.core.protolog.json +++ b/data/etc/services.core.protolog.json @@ -3433,6 +3433,12 @@ "group": "WM_DEBUG_FOCUS_LIGHT", "at": "com\/android\/server\/wm\/WindowState.java" }, + "1288920916": { + "message": "Error sending initial insets change to WindowContainer overlay", + "level": "ERROR", + "group": "WM_DEBUG_ANIM", + "at": "com\/android\/server\/wm\/WindowContainer.java" + }, "1305412562": { "message": "Report configuration: %s %s", "level": "VERBOSE", diff --git a/services/core/java/com/android/server/wm/WindowContainer.java b/services/core/java/com/android/server/wm/WindowContainer.java index 214524c2f42cc..f58a01e006316 100644 --- a/services/core/java/com/android/server/wm/WindowContainer.java +++ b/services/core/java/com/android/server/wm/WindowContainer.java @@ -3859,7 +3859,8 @@ class WindowContainer extends ConfigurationContainer< @AnimationType int type, @Nullable AnimationAdapter snapshotAnim); } - void addTrustedOverlay(SurfaceControlViewHost.SurfacePackage overlay) { + void addTrustedOverlay(SurfaceControlViewHost.SurfacePackage overlay, + @Nullable WindowState initialWindowState) { if (mOverlayHost == null) { mOverlayHost = new TrustedOverlayHost(mWmService); } @@ -3875,6 +3876,20 @@ class WindowContainer extends ConfigurationContainer< "Error sending initial configuration change to WindowContainer overlay"); removeTrustedOverlay(overlay); } + + // Emit an initial WindowState so that proper insets are available to overlay views + // shortly after the overlay is added. + if (initialWindowState != null) { + final InsetsState insetsState = initialWindowState.getInsetsState(); + final Rect dispBounds = getBounds(); + try { + overlay.getRemoteInterface().onInsetsChanged(insetsState, dispBounds); + } catch (Exception e) { + ProtoLog.e(WM_DEBUG_ANIM, + "Error sending initial insets change to WindowContainer overlay"); + removeTrustedOverlay(overlay); + } + } } void removeTrustedOverlay(SurfaceControlViewHost.SurfacePackage overlay) { diff --git a/services/core/java/com/android/server/wm/WindowManagerService.java b/services/core/java/com/android/server/wm/WindowManagerService.java index 77d31df0bee7b..4d262efd03d06 100644 --- a/services/core/java/com/android/server/wm/WindowManagerService.java +++ b/services/core/java/com/android/server/wm/WindowManagerService.java @@ -8135,7 +8135,7 @@ public class WindowManagerService extends IWindowManager.Stub if (task == null) { throw new IllegalArgumentException("no task with taskId" + taskId); } - task.addTrustedOverlay(overlay); + task.addTrustedOverlay(overlay, task.getTopVisibleAppMainWindow()); } } From 2c480f88e2a25cfd9a84c7781001f70e0e440714 Mon Sep 17 00:00:00 2001 From: Sergey Serokurov Date: Mon, 11 Apr 2022 15:54:28 -0700 Subject: [PATCH 2/2] Do stack collapse after stack reorder Bug: 223912200 Test: atest SystemUITests Change-Id: I10818e9c38c48c60686c16b492f4d0792474037b --- .../android/wm/shell/bubbles/BubbleController.java | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleController.java b/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleController.java index 1a1cd5b27c53b..b6fb82852c2f8 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleController.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleController.java @@ -1225,12 +1225,6 @@ public class BubbleController { mOverflowListener.applyUpdate(update); } - // Collapsing? Do this first before remaining steps. - if (update.expandedChanged && !update.expanded) { - mStackView.setExpanded(false); - mSysuiProxy.requestNotificationShadeTopUi(false, TAG); - } - // Do removals, if any. ArrayList> removedBubbles = new ArrayList<>(update.removedBubbles); @@ -1307,6 +1301,11 @@ public class BubbleController { mStackView.updateBubbleOrder(update.bubbles); } + if (update.expandedChanged && !update.expanded) { + mStackView.setExpanded(false); + mSysuiProxy.requestNotificationShadeTopUi(false, TAG); + } + if (update.selectionChanged && mStackView != null) { mStackView.setSelectedBubble(update.selectedBubble); if (update.selectedBubble != null) {