diff options
| author | 2020-07-18 17:20:32 +0900 | |
|---|---|---|
| committer | 2020-09-21 02:37:55 +0000 | |
| commit | 9223fc1f57daa53b626a51a27aab0a10bd96d809 (patch) | |
| tree | 066f0a67e9ada17bbd0b1823fab6143415572ff8 | |
| parent | 5835eaa4ab48e5def924218db840a896e471dc00 (diff) | |
[wm] Use existing parent window token for child windows
The child windows should be attached to the parent window rather than its window token.
The window token can be visible state only if it has child containers.
So, if the window token is created only for the child window, then it cannot be visible state.
Fixes: 168713890
Test: atest WmTests:WindowTokenTests
Change-Id: I3efa14fda7a5674a178b13ff6310a526e75e3b50
Merged-In: I3efa14fda7a5674a178b13ff6310a526e75e3b50
(cherry picked from commit 347196a3eeeb773140610bd15de685e65cc99fff)
| -rw-r--r-- | services/core/java/com/android/server/wm/WindowManagerService.java | 11 | ||||
| -rw-r--r-- | services/tests/wmtests/src/com/android/server/wm/WindowTokenTests.java | 4 |
2 files changed, 12 insertions, 3 deletions
diff --git a/services/core/java/com/android/server/wm/WindowManagerService.java b/services/core/java/com/android/server/wm/WindowManagerService.java index b7ac54f3470e..f0f8c7522d6f 100644 --- a/services/core/java/com/android/server/wm/WindowManagerService.java +++ b/services/core/java/com/android/server/wm/WindowManagerService.java @@ -1476,9 +1476,14 @@ public class WindowManagerService extends IWindowManager.Stub rootType, attrs.token, attrs.packageName)) { return WindowManagerGlobal.ADD_BAD_APP_TOKEN; } - final IBinder binder = attrs.token != null ? attrs.token : client.asBinder(); - token = new WindowToken(this, binder, type, false, displayContent, - session.mCanAddInternalSystemWindow, isRoundedCornerOverlay); + if (hasParent) { + // Use existing parent window token for child windows. + token = parentWindow.mToken; + } else { + final IBinder binder = attrs.token != null ? attrs.token : client.asBinder(); + token = new WindowToken(this, binder, type, false, displayContent, + session.mCanAddInternalSystemWindow, isRoundedCornerOverlay); + } } else if (rootType >= FIRST_APPLICATION_WINDOW && rootType <= LAST_APPLICATION_WINDOW) { activity = token.asActivityRecord(); diff --git a/services/tests/wmtests/src/com/android/server/wm/WindowTokenTests.java b/services/tests/wmtests/src/com/android/server/wm/WindowTokenTests.java index 0896db4b5532..0ab99122e21f 100644 --- a/services/tests/wmtests/src/com/android/server/wm/WindowTokenTests.java +++ b/services/tests/wmtests/src/com/android/server/wm/WindowTokenTests.java @@ -78,6 +78,10 @@ public class WindowTokenTests extends WindowTestsBase { assertFalse(token.hasWindow(window12)); assertTrue(token.hasWindow(window2)); assertTrue(token.hasWindow(window3)); + + // The child windows should have the same window token as their parents. + assertEquals(window1.mToken, window11.mToken); + assertEquals(window1.mToken, window12.mToken); } @Test |