Loading services/core/java/com/android/server/wm/ActivityRecord.java +2 −1 Original line number Diff line number Diff line Loading @@ -2256,7 +2256,8 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A return false; } if (mRootActivityContainer.getTopResumedActivity() == this) { if (mRootActivityContainer.getTopResumedActivity() == this && getDisplayContent().mFocusedApp == this) { if (DEBUG_FOCUS) { Slog.d(TAG_FOCUS, "moveActivityStackToFront: already on top, activity=" + this); } Loading services/core/java/com/android/server/wm/DisplayContent.java +5 −1 Original line number Diff line number Diff line Loading @@ -4110,7 +4110,11 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo super.positionChildAt(currentPosition, child, false /* includingParents */); return; } // We don't allow untrusted display to top when task stack moves to top, // until user tapping this display to change display position as top intentionally. if (isUntrustedVirtualDisplay() && !getParent().isOnTop()) { includingParents = false; } final int targetPosition = findPositionForStack(position, child, false /* adding */); super.positionChildAt(targetPosition, child, includingParents); Loading services/core/java/com/android/server/wm/RootWindowContainer.java +6 −0 Original line number Diff line number Diff line Loading @@ -201,6 +201,12 @@ class RootWindowContainer extends WindowContainer<DisplayContent> return dc != null ? dc : getDisplayContent(DEFAULT_DISPLAY); } @Override boolean isOnTop() { // Considered always on top return true; } @Override void onChildPositionChanged(WindowContainer child) { mWmService.updateFocusedWindowLocked(UPDATE_FOCUS_NORMAL, Loading services/core/java/com/android/server/wm/WindowManagerService.java +5 −8 Original line number Diff line number Diff line Loading @@ -7612,12 +7612,15 @@ public class WindowManagerService extends IWindowManager.Stub // it as if the host window was tapped. touchedWindow = mEmbeddedWindowController.getHostWindow(touchedToken); } if (touchedWindow == null || !touchedWindow.canReceiveKeys()) { if (touchedWindow == null || !touchedWindow.canReceiveKeys(true /* fromUserTouch */)) { // If the window that received the input event cannot receive keys, don't move the // display it's on to the top since that window won't be able to get focus anyway. return; } handleTaskFocusChange(touchedWindow.getTask()); handleDisplayFocusChange(touchedWindow); handleTaskFocusChange(touchedWindow.getTask()); } private void handleTaskFocusChange(Task task) { Loading Loading @@ -7645,12 +7648,6 @@ public class WindowManagerService extends IWindowManager.Stub return; } if (!window.canReceiveKeys()) { // If the window that received the input event cannot receive keys, don't move the // display it's on to the top since that window won't be able to get focus anyway. return; } final WindowContainer parent = displayContent.getParent(); if (parent != null && parent.getTopChild() != displayContent) { parent.positionChildAt(WindowContainer.POSITION_TOP, displayContent, Loading services/core/java/com/android/server/wm/WindowState.java +12 −1 Original line number Diff line number Diff line Loading @@ -2616,11 +2616,22 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP @Override public boolean canReceiveKeys() { return isVisibleOrAdding() return canReceiveKeys(false /* fromUserTouch */); } public boolean canReceiveKeys(boolean fromUserTouch) { final boolean canReceiveKeys = isVisibleOrAdding() && (mViewVisibility == View.VISIBLE) && !mRemoveOnExit && ((mAttrs.flags & WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE) == 0) && (mActivityRecord == null || mActivityRecord.windowsAreFocusable()) && !cantReceiveTouchInput(); if (!canReceiveKeys) { return false; } // Do not allow untrusted virtual display to receive keys unless user intentionally // touches the display. return fromUserTouch || getDisplayContent().isOnTop() || !getDisplayContent().isUntrustedVirtualDisplay(); } @Override Loading Loading
services/core/java/com/android/server/wm/ActivityRecord.java +2 −1 Original line number Diff line number Diff line Loading @@ -2256,7 +2256,8 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A return false; } if (mRootActivityContainer.getTopResumedActivity() == this) { if (mRootActivityContainer.getTopResumedActivity() == this && getDisplayContent().mFocusedApp == this) { if (DEBUG_FOCUS) { Slog.d(TAG_FOCUS, "moveActivityStackToFront: already on top, activity=" + this); } Loading
services/core/java/com/android/server/wm/DisplayContent.java +5 −1 Original line number Diff line number Diff line Loading @@ -4110,7 +4110,11 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo super.positionChildAt(currentPosition, child, false /* includingParents */); return; } // We don't allow untrusted display to top when task stack moves to top, // until user tapping this display to change display position as top intentionally. if (isUntrustedVirtualDisplay() && !getParent().isOnTop()) { includingParents = false; } final int targetPosition = findPositionForStack(position, child, false /* adding */); super.positionChildAt(targetPosition, child, includingParents); Loading
services/core/java/com/android/server/wm/RootWindowContainer.java +6 −0 Original line number Diff line number Diff line Loading @@ -201,6 +201,12 @@ class RootWindowContainer extends WindowContainer<DisplayContent> return dc != null ? dc : getDisplayContent(DEFAULT_DISPLAY); } @Override boolean isOnTop() { // Considered always on top return true; } @Override void onChildPositionChanged(WindowContainer child) { mWmService.updateFocusedWindowLocked(UPDATE_FOCUS_NORMAL, Loading
services/core/java/com/android/server/wm/WindowManagerService.java +5 −8 Original line number Diff line number Diff line Loading @@ -7612,12 +7612,15 @@ public class WindowManagerService extends IWindowManager.Stub // it as if the host window was tapped. touchedWindow = mEmbeddedWindowController.getHostWindow(touchedToken); } if (touchedWindow == null || !touchedWindow.canReceiveKeys()) { if (touchedWindow == null || !touchedWindow.canReceiveKeys(true /* fromUserTouch */)) { // If the window that received the input event cannot receive keys, don't move the // display it's on to the top since that window won't be able to get focus anyway. return; } handleTaskFocusChange(touchedWindow.getTask()); handleDisplayFocusChange(touchedWindow); handleTaskFocusChange(touchedWindow.getTask()); } private void handleTaskFocusChange(Task task) { Loading Loading @@ -7645,12 +7648,6 @@ public class WindowManagerService extends IWindowManager.Stub return; } if (!window.canReceiveKeys()) { // If the window that received the input event cannot receive keys, don't move the // display it's on to the top since that window won't be able to get focus anyway. return; } final WindowContainer parent = displayContent.getParent(); if (parent != null && parent.getTopChild() != displayContent) { parent.positionChildAt(WindowContainer.POSITION_TOP, displayContent, Loading
services/core/java/com/android/server/wm/WindowState.java +12 −1 Original line number Diff line number Diff line Loading @@ -2616,11 +2616,22 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP @Override public boolean canReceiveKeys() { return isVisibleOrAdding() return canReceiveKeys(false /* fromUserTouch */); } public boolean canReceiveKeys(boolean fromUserTouch) { final boolean canReceiveKeys = isVisibleOrAdding() && (mViewVisibility == View.VISIBLE) && !mRemoveOnExit && ((mAttrs.flags & WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE) == 0) && (mActivityRecord == null || mActivityRecord.windowsAreFocusable()) && !cantReceiveTouchInput(); if (!canReceiveKeys) { return false; } // Do not allow untrusted virtual display to receive keys unless user intentionally // touches the display. return fromUserTouch || getDisplayContent().isOnTop() || !getDisplayContent().isUntrustedVirtualDisplay(); } @Override Loading