From ce87a68694c172da7b35f4a1df7ddd56fd37b396 Mon Sep 17 00:00:00 2001 From: Tiger Huang Date: Tue, 5 Oct 2021 17:03:01 +0800 Subject: [PATCH] Remove parent window from display content This CL removes the logic related to the legacy ActivityView. Bug: 179161778 Bug: 161810301 Test: build and boot to home. Change-Id: I757769d3cac89ebddbdc467f533fed99c74941ee --- .../view/AccessibilityEmbeddedConnection.java | 1 - .../AccessibilityInteractionController.java | 16 --- core/java/android/view/IWindow.aidl | 6 - core/java/android/view/IWindowManager.aidl | 10 -- core/java/android/view/IWindowSession.aidl | 11 -- core/java/android/view/View.java | 6 - core/java/android/view/ViewRootImpl.java | 32 ----- .../android/view/WindowlessWindowManager.java | 5 - .../android/internal/view/BaseIWindow.java | 5 - .../wm/shell/common/SystemWindows.java | 4 - .../server/wm/AccessibilityController.java | 25 ---- .../com/android/server/wm/DisplayContent.java | 85 +------------- .../java/com/android/server/wm/Session.java | 5 - .../server/wm/WindowManagerService.java | 59 ---------- .../com/android/server/wm/WindowState.java | 111 +----------------- .../server/wm/DisplayContentTests.java | 13 -- .../com/android/server/wm/TestIWindow.java | 5 - .../android/server/wm/WindowStateTests.java | 20 ---- 18 files changed, 5 insertions(+), 414 deletions(-) diff --git a/core/java/android/view/AccessibilityEmbeddedConnection.java b/core/java/android/view/AccessibilityEmbeddedConnection.java index 5d3466907ea20..de895d9c2e8e4 100644 --- a/core/java/android/view/AccessibilityEmbeddedConnection.java +++ b/core/java/android/view/AccessibilityEmbeddedConnection.java @@ -63,7 +63,6 @@ final class AccessibilityEmbeddedConnection extends IAccessibilityEmbeddedConnec viewRootImpl.mContext); viewRootImpl.mAttachInfo.mLeashedParentToken = null; viewRootImpl.mAttachInfo.mLeashedParentAccessibilityViewId = View.NO_ID; - viewRootImpl.mAttachInfo.mLocationInParentDisplay.set(0, 0); if (accessibilityManager.isEnabled()) { accessibilityManager.disassociateEmbeddedHierarchy(viewRootImpl.mLeashToken); } diff --git a/core/java/android/view/AccessibilityInteractionController.java b/core/java/android/view/AccessibilityInteractionController.java index 656fdbd7131a0..9cd83135821bd 100644 --- a/core/java/android/view/AccessibilityInteractionController.java +++ b/core/java/android/view/AccessibilityInteractionController.java @@ -878,21 +878,6 @@ public final class AccessibilityInteractionController { return false; } - private void adjustBoundsInScreenIfNeeded(AccessibilityNodeInfo info) { - if (info == null || shouldBypassAdjustBoundsInScreen()) { - return; - } - final Rect boundsInScreen = mTempRect; - info.getBoundsInScreen(boundsInScreen); - boundsInScreen.offset(mViewRootImpl.mAttachInfo.mLocationInParentDisplay.x, - mViewRootImpl.mAttachInfo.mLocationInParentDisplay.y); - info.setBoundsInScreen(boundsInScreen); - } - - private boolean shouldBypassAdjustBoundsInScreen() { - return mViewRootImpl.mAttachInfo.mLocationInParentDisplay.equals(0, 0); - } - private void applyScreenMatrixIfNeeded(List infos) { if (infos == null || shouldBypassApplyScreenMatrix()) { return; @@ -1009,7 +994,6 @@ public final class AccessibilityInteractionController { Region interactiveRegion) { associateLeashedParentIfNeeded(info); applyScreenMatrixIfNeeded(info); - adjustBoundsInScreenIfNeeded(info); // To avoid applyAppScaleAndMagnificationSpecIfNeeded changing the bounds of node, // then impact the visibility result, we need to adjust visibility before apply scale. adjustIsVisibleToUserIfNeeded(info, interactiveRegion); diff --git a/core/java/android/view/IWindow.aidl b/core/java/android/view/IWindow.aidl index b8b13b9ed88a4..2ee112b97dcd9 100644 --- a/core/java/android/view/IWindow.aidl +++ b/core/java/android/view/IWindow.aidl @@ -57,12 +57,6 @@ oneway interface IWindow { in MergedConfiguration newMergedConfiguration, boolean forceLayout, boolean alwaysConsumeSystemBars, int displayId); - /** - * Called when the window location in parent display has changed. The offset will only be a - * nonzero value if the window is on an embedded display that is re-parented to another window. - */ - void locationInParentDisplayChanged(in Point offset); - /** * Called when the window insets configuration has changed. * diff --git a/core/java/android/view/IWindowManager.aidl b/core/java/android/view/IWindowManager.aidl index ae2eed8aee017..f7d32d08c3821 100644 --- a/core/java/android/view/IWindowManager.aidl +++ b/core/java/android/view/IWindowManager.aidl @@ -547,16 +547,6 @@ interface IWindowManager */ boolean isWindowTraceEnabled(); - /** - * Notify WindowManager that it should not override the info in DisplayManager for the specified - * display. This can disable letter- or pillar-boxing applied in DisplayManager when the metrics - * of the logical display reported from WindowManager do not correspond to the metrics of the - * physical display it is based on. - * - * @param displayId The id of the display. - */ - void dontOverrideDisplayInfo(int displayId); - /** * Gets the windowing mode of the display. * diff --git a/core/java/android/view/IWindowSession.aidl b/core/java/android/view/IWindowSession.aidl index 9da50889e43f9..921ce53b3bda9 100644 --- a/core/java/android/view/IWindowSession.aidl +++ b/core/java/android/view/IWindowSession.aidl @@ -272,17 +272,6 @@ interface IWindowSession { oneway void updatePointerIcon(IWindow window); - /** - * Update the location of a child display in its parent window. This enables windows in the - * child display to compute the global transformation matrix. - * - * @param window The parent window of the display. - * @param x The x coordinate in the parent window. - * @param y The y coordinate in the parent window. - * @param displayId The id of the display to be notified. - */ - oneway void updateDisplayContentLocation(IWindow window, int x, int y, int displayId); - /** * Update a tap exclude region identified by provided id in the window. Touches on this region * will neither be dispatched to this window nor change the focus to this window. Passing an diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java index 6420236dbb3d3..bbdbb9bcfde21 100644 --- a/core/java/android/view/View.java +++ b/core/java/android/view/View.java @@ -29519,12 +29519,6 @@ public class View implements Drawable.Callback, KeyEvent.Callback, */ boolean mHandlingPointerEvent; - /** - * The offset of this view's window when it's on an embedded display that is re-parented - * to another window. - */ - final Point mLocationInParentDisplay = new Point(); - /** * The screen matrix of this view when it's on a {@link SurfaceControlViewHost} that is * embedded within a SurfaceView. diff --git a/core/java/android/view/ViewRootImpl.java b/core/java/android/view/ViewRootImpl.java index 9af0a022acc66..15d5555afcc9d 100644 --- a/core/java/android/view/ViewRootImpl.java +++ b/core/java/android/view/ViewRootImpl.java @@ -4685,13 +4685,6 @@ public final class ViewRootImpl implements ViewParent, } } - void updateLocationInParentDisplay(int x, int y) { - if (mAttachInfo != null - && !mAttachInfo.mLocationInParentDisplay.equals(x, y)) { - mAttachInfo.mLocationInParentDisplay.set(x, y); - } - } - /** * Set the root-level system gesture exclusion rects. These are added to those provided by * the root's view hierarchy. @@ -5203,7 +5196,6 @@ public final class ViewRootImpl implements ViewParent, private static final int MSG_INSETS_CHANGED = 30; private static final int MSG_INSETS_CONTROL_CHANGED = 31; private static final int MSG_SYSTEM_GESTURE_EXCLUSION_CHANGED = 32; - private static final int MSG_LOCATION_IN_PARENT_DISPLAY_CHANGED = 33; private static final int MSG_SHOW_INSETS = 34; private static final int MSG_HIDE_INSETS = 35; private static final int MSG_REQUEST_SCROLL_CAPTURE = 36; @@ -5269,8 +5261,6 @@ public final class ViewRootImpl implements ViewParent, return "MSG_INSETS_CONTROL_CHANGED"; case MSG_SYSTEM_GESTURE_EXCLUSION_CHANGED: return "MSG_SYSTEM_GESTURE_EXCLUSION_CHANGED"; - case MSG_LOCATION_IN_PARENT_DISPLAY_CHANGED: - return "MSG_LOCATION_IN_PARENT_DISPLAY_CHANGED"; case MSG_SHOW_INSETS: return "MSG_SHOW_INSETS"; case MSG_HIDE_INSETS: @@ -5496,9 +5486,6 @@ public final class ViewRootImpl implements ViewParent, case MSG_SYSTEM_GESTURE_EXCLUSION_CHANGED: { systemGestureExclusionChanged(); } break; - case MSG_LOCATION_IN_PARENT_DISPLAY_CHANGED: { - updateLocationInParentDisplay(msg.arg1, msg.arg2); - } break; case MSG_REQUEST_SCROLL_CAPTURE: handleScrollCaptureRequest((IScrollCaptureResponseListener) msg.obj); break; @@ -9030,17 +9017,6 @@ public final class ViewRootImpl implements ViewParent, mHandler.sendMessage(msg); } - /** - * Dispatch the offset changed. - * - * @param offset the offset of this view in the parent window. - */ - public void dispatchLocationInParentDisplayChanged(Point offset) { - Message msg = - mHandler.obtainMessage(MSG_LOCATION_IN_PARENT_DISPLAY_CHANGED, offset.x, offset.y); - mHandler.sendMessage(msg); - } - public void windowFocusChanged(boolean hasFocus, boolean inTouchMode) { synchronized (this) { mWindowFocusChanged = true; @@ -9715,14 +9691,6 @@ public final class ViewRootImpl implements ViewParent, } } - @Override - public void locationInParentDisplayChanged(Point offset) { - final ViewRootImpl viewAncestor = mViewAncestor.get(); - if (viewAncestor != null) { - viewAncestor.dispatchLocationInParentDisplayChanged(offset); - } - } - @Override public void insetsChanged(InsetsState insetsState, boolean willMove, boolean willResize) { final ViewRootImpl viewAncestor = mViewAncestor.get(); diff --git a/core/java/android/view/WindowlessWindowManager.java b/core/java/android/view/WindowlessWindowManager.java index ffb7efa672432..d699194dd77f0 100644 --- a/core/java/android/view/WindowlessWindowManager.java +++ b/core/java/android/view/WindowlessWindowManager.java @@ -443,11 +443,6 @@ public class WindowlessWindowManager implements IWindowSession { public void updatePointerIcon(android.view.IWindow window) { } - @Override - public void updateDisplayContentLocation(android.view.IWindow window, int x, int y, - int displayId) { - } - @Override public void updateTapExcludeRegion(android.view.IWindow window, android.graphics.Region region) { diff --git a/core/java/com/android/internal/view/BaseIWindow.java b/core/java/com/android/internal/view/BaseIWindow.java index f212fc7d12287..9e741e2aa551f 100644 --- a/core/java/com/android/internal/view/BaseIWindow.java +++ b/core/java/com/android/internal/view/BaseIWindow.java @@ -17,7 +17,6 @@ package com.android.internal.view; import android.compat.annotation.UnsupportedAppUsage; -import android.graphics.Point; import android.hardware.input.InputManager; import android.os.Bundle; import android.os.ParcelFileDescriptor; @@ -61,10 +60,6 @@ public class BaseIWindow extends IWindow.Stub { } } - @Override - public void locationInParentDisplayChanged(Point offset) { - } - @Override public void insetsChanged(InsetsState insetsState, boolean willMove, boolean willResize) { } diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/common/SystemWindows.java b/libs/WindowManager/Shell/src/com/android/wm/shell/common/SystemWindows.java index 97c89d042be0d..33ce383f7f9e2 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/common/SystemWindows.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/common/SystemWindows.java @@ -21,7 +21,6 @@ import static android.view.WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED; import android.annotation.NonNull; import android.content.Context; import android.content.res.Configuration; -import android.graphics.Point; import android.graphics.Region; import android.os.Bundle; import android.os.IBinder; @@ -334,9 +333,6 @@ public class SystemWindows { MergedConfiguration newMergedConfiguration, boolean forceLayout, boolean alwaysConsumeSystemBars, int displayId) {} - @Override - public void locationInParentDisplayChanged(Point offset) {} - @Override public void insetsChanged(InsetsState insetsState, boolean willMove, boolean willResize) {} diff --git a/services/core/java/com/android/server/wm/AccessibilityController.java b/services/core/java/com/android/server/wm/AccessibilityController.java index 54414141e62a1..52b300b01bae3 100644 --- a/services/core/java/com/android/server/wm/AccessibilityController.java +++ b/services/core/java/com/android/server/wm/AccessibilityController.java @@ -1838,36 +1838,11 @@ final class AccessibilityController { tempWindowStatesList.add(w); } }, false /* traverseTopToBottom */); - // Insert the re-parented windows in another display below their parents in - // default display. - mService.mRoot.forAllWindows(w -> { - final WindowState parentWindow = findRootDisplayParentWindow(w); - if (parentWindow == null) { - return; - } - - if (w.isVisible() && tempWindowStatesList.contains(parentWindow)) { - tempWindowStatesList.add(tempWindowStatesList.lastIndexOf(parentWindow), w); - } - }, false /* traverseTopToBottom */); for (int i = 0; i < tempWindowStatesList.size(); i++) { outWindows.put(i, tempWindowStatesList.get(i)); } } - private WindowState findRootDisplayParentWindow(WindowState win) { - WindowState displayParentWindow = win.getDisplayContent().getParentWindow(); - if (displayParentWindow == null) { - return null; - } - WindowState candidate = displayParentWindow; - while (candidate != null) { - displayParentWindow = candidate; - candidate = displayParentWindow.getDisplayContent().getParentWindow(); - } - return displayParentWindow; - } - private WindowState getTopFocusWindow() { return mService.mRoot.getTopFocusedDisplayContent().mCurrentFocus; } diff --git a/services/core/java/com/android/server/wm/DisplayContent.java b/services/core/java/com/android/server/wm/DisplayContent.java index 9d51b6f8d82fb..e71319b6d797b 100644 --- a/services/core/java/com/android/server/wm/DisplayContent.java +++ b/services/core/java/com/android/server/wm/DisplayContent.java @@ -467,12 +467,6 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp @VisibleForTesting boolean isDefaultDisplay; - /** - * Flag indicating whether WindowManager should override info for this display in - * DisplayManager. - */ - boolean mShouldOverrideDisplayConfiguration = true; - /** Window tokens that are in the process of exiting, but still on screen for animations. */ final ArrayList mExitingTokens = new ArrayList<>(); @@ -655,11 +649,6 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp private final InsetsStateController mInsetsStateController; private final InsetsPolicy mInsetsPolicy; - /** @see #getParentWindow() */ - private WindowState mParentWindow; - - private Point mLocationInParentWindow = new Point(); - /** Corner radius that windows should have in order to match the display. */ private final float mWindowCornerRadius; @@ -860,7 +849,6 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp w.updateLastFrames(); } w.onResizeHandled(); - w.updateLocationInParentDisplayIfNeeded(); } if (w.mActivityRecord != null) { @@ -2024,14 +2012,8 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp computeSizeRangesAndScreenLayout(mDisplayInfo, rotated, uiMode, dw, dh, mDisplayMetrics.density, outConfig); - // We usually set the override info in DisplayManager so that we get consistent display - // metrics values when displays are changing and don't send out new values until WM is aware - // of them. However, we don't do this for displays that serve as containers for ActivityView - // because we don't want letter-/pillar-boxing during resize. - final DisplayInfo overrideDisplayInfo = mShouldOverrideDisplayConfiguration - ? mDisplayInfo : null; mWmService.mDisplayManagerInternal.setDisplayInfoOverrideFromWindowManager(mDisplayId, - overrideDisplayInfo); + mDisplayInfo); mBaseDisplayRect.set(0, 0, dw, dh); @@ -3076,9 +3058,6 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp void removeImmediately() { mDeferredRemoval = false; try { - if (mParentWindow != null) { - mParentWindow.removeEmbeddedDisplayContent(this); - } // Clear all transitions & screen frozen states when removing display. mOpeningApps.clear(); mClosingApps.clear(); @@ -3830,8 +3809,7 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp /** * Finds the window which can host IME if IME target cannot host it. - * e.g. IME target cannot host IME when it's display has a parent display OR when display - * doesn't support IME/system decorations. + * e.g. IME target cannot host IME when display doesn't support IME/system decorations. * * @param target current IME target. * @return {@link InsetsControlTarget} that can host IME. @@ -5185,65 +5163,6 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp && isTrusted(); } - /** - * Get the window which owns the surface that this DisplayContent is re-parented to. - * - * @return the parent window. - */ - WindowState getParentWindow() { - return mParentWindow; - } - - /** - * Update the location of this display in the parent window. This enables windows in this - * display to compute the global transformation matrix. - * - * @param win The parent window of this display. - * @param x The x coordinate in the parent window. - * @param y The y coordinate in the parent window. - */ - void updateLocation(WindowState win, int x, int y) { - if (mParentWindow != win) { - throw new IllegalArgumentException( - "The given window is not the parent window of this display."); - } - if (!mLocationInParentWindow.equals(x, y)) { - mLocationInParentWindow.set(x, y); - if (mWmService.mAccessibilityController.hasCallbacks()) { - mWmService.mAccessibilityController.onSomeWindowResizedOrMoved(mDisplayId); - } - notifyLocationInParentDisplayChanged(); - } - } - - Point getLocationInParentWindow() { - return mLocationInParentWindow; - } - - Point getLocationInParentDisplay() { - final Point location = new Point(); - if (mParentWindow != null) { - // LocationInParentWindow indicates the offset to (0,0) of window, but what we need is - // the offset to (0,0) of display. - DisplayContent dc = this; - do { - final WindowState displayParent = dc.getParentWindow(); - location.x += displayParent.getFrame().left - + (dc.getLocationInParentWindow().x * displayParent.mGlobalScale + 0.5f); - location.y += displayParent.getFrame().top - + (dc.getLocationInParentWindow().y * displayParent.mGlobalScale + 0.5f); - dc = displayParent.getDisplayContent(); - } while (dc != null && dc.getParentWindow() != null); - } - return location; - } - - void notifyLocationInParentDisplayChanged() { - forAllWindows(w -> { - w.updateLocationInParentDisplayIfNeeded(); - }, false /* traverseTopToBottom */); - } - SurfaceControl getWindowingLayer() { return mWindowingLayer; } diff --git a/services/core/java/com/android/server/wm/Session.java b/services/core/java/com/android/server/wm/Session.java index 8c056b2a43b39..6b7f92a102d96 100644 --- a/services/core/java/com/android/server/wm/Session.java +++ b/services/core/java/com/android/server/wm/Session.java @@ -619,11 +619,6 @@ class Session extends IWindowSession.Stub implements IBinder.DeathRecipient { } } - @Override - public void updateDisplayContentLocation(IWindow window, int x, int y, int displayId) { - mService.updateDisplayContentLocation(window, x, y, displayId); - } - @Override public void updateTapExcludeRegion(IWindow window, Region region) { final long identity = Binder.clearCallingIdentity(); diff --git a/services/core/java/com/android/server/wm/WindowManagerService.java b/services/core/java/com/android/server/wm/WindowManagerService.java index 50c3d3ca10d66..cde1b1a8c68e2 100644 --- a/services/core/java/com/android/server/wm/WindowManagerService.java +++ b/services/core/java/com/android/server/wm/WindowManagerService.java @@ -7045,42 +7045,6 @@ public class WindowManagerService extends IWindowManager.Stub } } - private void checkCallerOwnsDisplay(int displayId) { - final Display display = mDisplayManager.getDisplay(displayId); - if (display == null) { - throw new IllegalArgumentException( - "Cannot find display for non-existent displayId: " + displayId); - } - - final int callingUid = Binder.getCallingUid(); - final int displayOwnerUid = display.getOwnerUid(); - if (callingUid != displayOwnerUid) { - throw new SecurityException("The caller doesn't own the display."); - } - } - - /** @see Session#updateDisplayContentLocation(IWindow, int, int, int) */ - void updateDisplayContentLocation(IWindow client, int x, int y, int displayId) { - checkCallerOwnsDisplay(displayId); - - synchronized (mGlobalLock) { - final long token = Binder.clearCallingIdentity(); - try { - final WindowState win = windowForClientLocked(null, client, false); - if (win == null) { - ProtoLog.w(WM_ERROR, "Bad requesting window %s", client); - return; - } - final DisplayContent displayContent = mRoot.getDisplayContent(displayId); - if (displayContent != null) { - displayContent.updateLocation(win, x, y); - } - } finally { - Binder.restoreCallingIdentity(token); - } - } - } - /** * Update a tap exclude region in the window identified by the provided id. Touches down on this * region will not: @@ -7158,29 +7122,6 @@ public class WindowManagerService extends IWindowManager.Stub } } - @Override - public void dontOverrideDisplayInfo(int displayId) { - final long token = Binder.clearCallingIdentity(); - try { - synchronized (mGlobalLock) { - final DisplayContent dc = getDisplayContentOrCreate(displayId, null /* token */); - if (dc == null) { - throw new IllegalArgumentException( - "Trying to configure a non existent display."); - } - // We usually set the override info in DisplayManager so that we get consistent - // values when displays are changing. However, we don't do this for displays that - // serve as containers for ActivityViews because we don't want letter-/pillar-boxing - // during resize. - dc.mShouldOverrideDisplayConfiguration = false; - mDisplayManagerInternal.setDisplayInfoOverrideFromWindowManager(displayId, - null /* info */); - } - } finally { - Binder.restoreCallingIdentity(token); - } - } - @Override public int getWindowingMode(int displayId) { if (!checkCallingPermission(INTERNAL_SYSTEM_WINDOW, "getWindowingMode()")) { diff --git a/services/core/java/com/android/server/wm/WindowState.java b/services/core/java/com/android/server/wm/WindowState.java index 9268d820c5f96..cca4601d510d6 100644 --- a/services/core/java/com/android/server/wm/WindowState.java +++ b/services/core/java/com/android/server/wm/WindowState.java @@ -216,7 +216,6 @@ import android.os.Trace; import android.os.WorkSource; import android.provider.Settings; import android.text.TextUtils; -import android.util.ArraySet; import android.util.DisplayMetrics; import android.util.MergedConfiguration; import android.util.Slog; @@ -405,9 +404,6 @@ class WindowState extends WindowContainer implements WindowManagerP int mLayoutSeq = -1; - /** @see #addEmbeddedDisplayContent(DisplayContent dc) */ - private final ArraySet mEmbeddedDisplayContents = new ArraySet<>(); - /** * Used to store last reported to client configuration and check if we have newer available. * We'll send configuration to client only if it is different from the last applied one and @@ -668,12 +664,6 @@ class WindowState extends WindowContainer implements WindowManagerP private final Transaction mTmpTransaction; - /** - * If a window is on a display which has been re-parented to a view in another window, - * use this offset to indicate the correct location. - */ - private final Point mLastReportedDisplayOffset = new Point(); - /** * Whether the window was resized by us while it was gone for layout. */ @@ -2291,7 +2281,6 @@ class WindowState extends WindowContainer implements WindowManagerP if (mWmService.mAccessibilityController.hasCallbacks()) { mWmService.mAccessibilityController.onSomeWindowResizedOrMoved(getDisplayId()); } - updateLocationInParentDisplayIfNeeded(); try { mClient.moved(left, top); @@ -2638,29 +2627,7 @@ class WindowState extends WindowContainer implements WindowManagerP mHasSurface = hasSurface; } - /** - * Checks whether one of the Windows in a Display embedded in this Window can be an IME target. - */ - private boolean canWindowInEmbeddedDisplayBeImeTarget() { - final int embeddedDisplayContentsSize = mEmbeddedDisplayContents.size(); - for (int i = embeddedDisplayContentsSize - 1; i >= 0; i--) { - final DisplayContent edc = mEmbeddedDisplayContents.valueAt(i); - if (edc.forAllWindows(WindowState::canBeImeTarget, true)) { - return true; - } - } - return false; - } - boolean canBeImeTarget() { - // If any of the embedded windows can be the IME target, this window will be the final IME - // target. This is because embedded windows are on a different display in WM so it would - // cause confusion trying to set the IME to a window on a different display. Instead, just - // make the host window the IME target. - if (canWindowInEmbeddedDisplayBeImeTarget()) { - return true; - } - if (mIsImWindow) { // IME windows can't be IME targets. IME targets are required to be below the IME // windows and that wouldn't be possible if the IME window is its own target...silly. @@ -3947,7 +3914,6 @@ class WindowState extends WindowContainer implements WindowManagerP if (mWmService.mAccessibilityController.hasCallbacks()) { mWmService.mAccessibilityController.onSomeWindowResizedOrMoved(displayId); } - updateLocationInParentDisplayIfNeeded(); } catch (RemoteException e) { // Cancel orientation change of this window to avoid blocking unfreeze display. setOrientationChanging(false); @@ -3962,36 +3928,6 @@ class WindowState extends WindowContainer implements WindowManagerP return mClient instanceof IWindow.Stub; } - void updateLocationInParentDisplayIfNeeded() { - final int embeddedDisplayContentsSize = mEmbeddedDisplayContents.size(); - // If there is any embedded display which is re-parented to this window, we need to - // notify all windows in the embedded display about the location change. - if (embeddedDisplayContentsSize != 0) { - for (int i = embeddedDisplayContentsSize - 1; i >= 0; i--) { - final DisplayContent edc = mEmbeddedDisplayContents.valueAt(i); - edc.notifyLocationInParentDisplayChanged(); - } - } - // If this window is in a embedded display which is re-parented to another window, - // we may need to update its correct on-screen location. - final DisplayContent dc = getDisplayContent(); - if (dc.getParentWindow() == null) { - return; - } - - final Point offset = dc.getLocationInParentDisplay(); - if (mLastReportedDisplayOffset.equals(offset)) { - return; - } - - mLastReportedDisplayOffset.set(offset.x, offset.y); - try { - mClient.locationInParentDisplayChanged(mLastReportedDisplayOffset); - } catch (RemoteException e) { - Slog.e(TAG, "Failed to update offset from DisplayContent", e); - } - } - /** * Called when the insets state changed. */ @@ -4425,9 +4361,6 @@ class WindowState extends WindowContainer implements WindowManagerP } pw.println(prefix + "isOnScreen=" + isOnScreen()); pw.println(prefix + "isVisible=" + isVisible()); - if (!mEmbeddedDisplayContents.isEmpty()) { - pw.println(prefix + "mEmbeddedDisplayContents=" + mEmbeddedDisplayContents); - } if (dumpAll) { final String visibilityString = mRequestedVisibilities.toString(); if (!visibilityString.isEmpty()) { @@ -5253,28 +5186,6 @@ class WindowState extends WindowContainer implements WindowManagerP return mLayoutSeq != -1; } - /** - * Add the DisplayContent of the embedded display which is re-parented to this window to - * the list of embedded displays. - * - * @param dc DisplayContent of the re-parented embedded display. - * @return {@code true} if the giving DisplayContent is added, {@code false} otherwise. - */ - boolean addEmbeddedDisplayContent(DisplayContent dc) { - return mEmbeddedDisplayContents.add(dc); - } - - /** - * Remove the DisplayContent of the embedded display which is re-parented to this window from - * the list of embedded displays. - * - * @param dc DisplayContent of the re-parented embedded display. - * @return {@code true} if the giving DisplayContent is removed, {@code false} otherwise. - */ - boolean removeEmbeddedDisplayContent(DisplayContent dc) { - return mEmbeddedDisplayContents.remove(dc); - } - /** Updates the last frames and relative frames to the current ones. */ void updateLastFrames() { mWindowFrames.mLastFrame.set(mWindowFrames.mFrame); @@ -5360,18 +5271,6 @@ class WindowState extends WindowContainer implements WindowManagerP int x = mSurfacePosition.x + mTmpPoint.x; int y = mSurfacePosition.y + mTmpPoint.y; - // We might be on a display which has been re-parented to a view in another window, so here - // computes the global location of our display. - DisplayContent dc = getDisplayContent(); - while (dc != null && dc.getParentWindow() != null) { - final WindowState displayParent = dc.getParentWindow(); - x += displayParent.mWindowFrames.mFrame.left - + (dc.getLocationInParentWindow().x * displayParent.mGlobalScale + 0.5f); - y += displayParent.mWindowFrames.mFrame.top - + (dc.getLocationInParentWindow().y * displayParent.mGlobalScale + 0.5f); - dc = displayParent.getDisplayContent(); - } - // If changed, also adjust transformFrameToSurfacePosition final WindowContainer parent = getParent(); if (isChildWindow()) { @@ -5706,8 +5605,8 @@ class WindowState extends WindowContainer implements WindowManagerP } /** - * Get IME target that should host IME when this window's display has a parent. - * Note: IME is never hosted by a display that has a parent. + * Get IME target that should host IME. + * Note: IME is never hosted by a display that doesn't support IME/system decorations. * When window calling * {@link android.view.inputmethod.InputMethodManager#showSoftInput(View, int)} is unknown, * use {@link DisplayContent#getImeControlTarget()} instead. @@ -5716,11 +5615,7 @@ class WindowState extends WindowContainer implements WindowManagerP * When window is doesn't have a parent, it is returned as-is. */ InsetsControlTarget getImeControlTarget() { - final DisplayContent dc = getDisplayContent(); - final WindowState parentWindow = dc.getParentWindow(); - - // If target's display has a parent, IME is displayed in the parent display. - return dc.getImeHostOrFallback(parentWindow != null ? parentWindow : this); + return getDisplayContent().getImeHostOrFallback(this); } @Override diff --git a/services/tests/wmtests/src/com/android/server/wm/DisplayContentTests.java b/services/tests/wmtests/src/com/android/server/wm/DisplayContentTests.java index 24bbf4682157a..79918e2496ba5 100644 --- a/services/tests/wmtests/src/com/android/server/wm/DisplayContentTests.java +++ b/services/tests/wmtests/src/com/android/server/wm/DisplayContentTests.java @@ -73,7 +73,6 @@ import static com.android.dx.mockito.inline.extended.ExtendedMockito.never; import static com.android.dx.mockito.inline.extended.ExtendedMockito.reset; import static com.android.dx.mockito.inline.extended.ExtendedMockito.same; import static com.android.dx.mockito.inline.extended.ExtendedMockito.spyOn; -import static com.android.dx.mockito.inline.extended.ExtendedMockito.times; import static com.android.dx.mockito.inline.extended.ExtendedMockito.verify; import static com.android.server.wm.ActivityTaskSupervisor.ON_TOP; import static com.android.server.wm.DisplayContent.IME_TARGET_INPUT; @@ -870,18 +869,6 @@ public class DisplayContentTests extends WindowTestsBase { window.mAttrs.screenOrientation, dc.getOrientation()); } - @Test - public void testDisableDisplayInfoOverrideFromWindowManager() { - final DisplayContent dc = createNewDisplay(); - - assertTrue(dc.mShouldOverrideDisplayConfiguration); - mWm.dontOverrideDisplayInfo(dc.getDisplayId()); - - assertFalse(dc.mShouldOverrideDisplayConfiguration); - verify(mWm.mDisplayManagerInternal, times(1)) - .setDisplayInfoOverrideFromWindowManager(dc.getDisplayId(), null); - } - @Test public void testGetPreferredOptionsPanelGravityFromDifferentDisplays() { final DisplayContent portraitDisplay = createNewDisplay(); diff --git a/services/tests/wmtests/src/com/android/server/wm/TestIWindow.java b/services/tests/wmtests/src/com/android/server/wm/TestIWindow.java index 4c31ee2ae5fa6..b6701dd743126 100644 --- a/services/tests/wmtests/src/com/android/server/wm/TestIWindow.java +++ b/services/tests/wmtests/src/com/android/server/wm/TestIWindow.java @@ -16,7 +16,6 @@ package com.android.server.wm; -import android.graphics.Point; import android.os.Bundle; import android.os.ParcelFileDescriptor; import android.os.RemoteException; @@ -48,10 +47,6 @@ public class TestIWindow extends IWindow.Stub { int displayId) throws RemoteException { } - @Override - public void locationInParentDisplayChanged(Point offset) throws RemoteException { - } - @Override public void insetsChanged(InsetsState insetsState, boolean willMove, boolean willResize) { } diff --git a/services/tests/wmtests/src/com/android/server/wm/WindowStateTests.java b/services/tests/wmtests/src/com/android/server/wm/WindowStateTests.java index b17ea5e48db5d..1838015691bcf 100644 --- a/services/tests/wmtests/src/com/android/server/wm/WindowStateTests.java +++ b/services/tests/wmtests/src/com/android/server/wm/WindowStateTests.java @@ -276,26 +276,6 @@ public class WindowStateTests extends WindowTestsBase { assertTrue(rootTask.shouldIgnoreInput()); } - @Test - public void testCanWindowWithEmbeddedDisplayBeImeTarget() { - final WindowState appWindow = createWindow(null, TYPE_APPLICATION, "appWindow"); - final WindowState imeWindow = createWindow(null, TYPE_INPUT_METHOD, "imeWindow"); - - imeWindow.setHasSurface(true); - appWindow.setHasSurface(true); - - appWindow.mAttrs.flags |= FLAG_NOT_FOCUSABLE; - assertFalse(appWindow.canBeImeTarget()); - - DisplayContent secondDisplay = createNewDisplay(); - final WindowState embeddedWindow = createWindow(null, TYPE_APPLICATION, secondDisplay, - "embeddedWindow"); - appWindow.addEmbeddedDisplayContent(secondDisplay); - embeddedWindow.setHasSurface(true); - embeddedWindow.mAttrs.flags &= ~FLAG_NOT_FOCUSABLE; - assertTrue(appWindow.canBeImeTarget()); - } - @Test public void testGetWindow() { final WindowState root = createWindow(null, TYPE_APPLICATION, "root");