diff --git a/services/core/java/com/android/server/wm/DisplayContent.java b/services/core/java/com/android/server/wm/DisplayContent.java index 7f944454ecdf9..f35a7e6236658 100644 --- a/services/core/java/com/android/server/wm/DisplayContent.java +++ b/services/core/java/com/android/server/wm/DisplayContent.java @@ -70,7 +70,6 @@ import static android.view.WindowManager.LayoutParams.TYPE_ACCESSIBILITY_MAGNIFI import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION_STARTING; import static android.view.WindowManager.LayoutParams.TYPE_BASE_APPLICATION; import static android.view.WindowManager.LayoutParams.TYPE_BOOT_PROGRESS; -import static android.view.WindowManager.LayoutParams.TYPE_DOCK_DIVIDER; import static android.view.WindowManager.LayoutParams.TYPE_DREAM; import static android.view.WindowManager.LayoutParams.TYPE_INPUT_METHOD; import static android.view.WindowManager.LayoutParams.TYPE_INPUT_METHOD_DIALOG; @@ -304,8 +303,8 @@ class DisplayContent extends WindowContainer callback, boolean traverseTopToBottom) { - return mImeWindowsContainers.forAllWindows(callback, traverseTopToBottom); + return mImeWindowsContainers.forAllWindowForce(callback, traverseTopToBottom); } /** @@ -2339,11 +2342,15 @@ class DisplayContent extends WindowContainer= topChildPosition) { - getParent().positionChildAt(POSITION_TOP, this /* child */, - true /* includingParents */); - } + if (includingParents && (moveToTop || moveToBottom)) { + // The DisplayContent children do not re-order, but we still want to move the + // display of this stack container because the intention of positioning is to have + // higher z-order to gain focus. + positionDisplayAt(moveToTop ? POSITION_TOP : POSITION_BOTTOM, + true /* includingParents */); } setLayoutNeeded(); @@ -4636,39 +4640,12 @@ class DisplayContent extends WindowContainer= mWmService.mPolicy.getWindowLayerFromTypeLw( TYPE_INPUT_METHOD_DIALOG, true)) { - imeContainer.assignRelativeLayer(t, wt.getSurfaceControl(), -1); + mImeWindowsContainers.assignRelativeLayer(t, wt.getSurfaceControl(), -1); needAssignIme = false; } } - if (needAssignIme) { - imeContainer.assignRelativeLayer(t, getSurfaceControl(), Integer.MAX_VALUE); - } } } @@ -4697,6 +4671,7 @@ class DisplayContent extends WindowContainer callback, - boolean traverseTopToBottom) { - // Special handling so we can process IME windows with #forAllImeWindows above their IME - // target, or here in order if there isn't an IME target. - if (traverseTopToBottom) { - for (int i = mChildren.size() - 1; i >= 0; --i) { - final WindowContainer child = mChildren.get(i); - if (skipTraverseChild(child)) { - continue; - } - - if (child.forAllWindows(callback, traverseTopToBottom)) { - return true; - } - } - } else { - final int count = mChildren.size(); - for (int i = 0; i < count; i++) { - final WindowContainer child = mChildren.get(i); - if (skipTraverseChild(child)) { - continue; - } - - if (child.forAllWindows(callback, traverseTopToBottom)) { - return true; - } - } - } - return false; - } - @Override void positionChildAt(int position, WindowContainer child, boolean includingParents) { // Children of the WindowContainers are statically ordered, so the real intention here @@ -4910,6 +4843,68 @@ class DisplayContent extends WindowContainer callback, + boolean traverseTopToBottom) { + final DisplayContent dc = mDisplayContent; + if (skipImeWindowsDuringTraversal(dc)) { + return false; + } + return super.forAllWindows(callback, traverseTopToBottom); + } + + private boolean skipImeWindowsDuringTraversal(DisplayContent dc) { + // We skip IME windows so they're processed just above their target, except + // in split-screen mode where we process the IME containers above the docked divider. + return dc.mInputMethodTarget != null && !dc.hasSplitScreenPrimaryStack(); + } + + /** Like {@link #forAllWindows}, but ignores {@link #skipImeWindowsDuringTraversal} */ + boolean forAllWindowForce(ToBooleanFunction callback, + boolean traverseTopToBottom) { + return super.forAllWindows(callback, traverseTopToBottom); + } + + @Override + void assignLayer(Transaction t, int layer) { + if (!mNeedsLayer) { + return; + } + super.assignLayer(t, layer); + mNeedsLayer = false; + } + + @Override + void assignRelativeLayer(Transaction t, SurfaceControl relativeTo, int layer) { + if (!mNeedsLayer) { + return; + } + super.assignRelativeLayer(t, relativeTo, layer); + mNeedsLayer = false; + } + } + @Override SurfaceSession getSession() { return mSession; @@ -5013,6 +5008,7 @@ class DisplayContent extends WindowContainer { super.onDisplayChanged(dc); } + @Override + void assignLayer(SurfaceControl.Transaction t, int layer) { + if (windowType == TYPE_DOCK_DIVIDER) { + // See {@link DisplayContent#mSplitScreenDividerAnchor} + super.assignRelativeLayer(t, mDisplayContent.getSplitScreenDividerAnchor(), 1); + } else if (mRoundedCornerOverlay) { + super.assignLayer(t, WindowManagerPolicy.COLOR_FADE_LAYER + 1); + } else { + super.assignLayer(t, layer); + } + } + + @Override + SurfaceControl.Builder makeSurface() { + final SurfaceControl.Builder builder = super.makeSurface(); + if (mRoundedCornerOverlay) { + builder.setParent(null); + } + return builder; + } + @CallSuper @Override public void dumpDebug(ProtoOutputStream proto, long fieldId, @@ -315,4 +339,8 @@ class WindowToken extends WindowContainer { mOwnerCanManageAppTokens); return mOwnerCanManageAppTokens && (layer > navLayer); } + + int getWindowLayerFromType() { + return mWmService.mPolicy.getWindowLayerFromTypeLw(windowType, mOwnerCanManageAppTokens); + } }