[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.

Test: atest WmTests:WindowTokenTests
Change-Id: I3efa14fda7a5674a178b13ff6310a526e75e3b50
This commit is contained in:
b0202.jung
2020-07-18 17:20:32 +09:00
committed by Wale Ogunwale
parent dc91aaab2d
commit 347196a3ee
2 changed files with 12 additions and 3 deletions

View File

@@ -1478,9 +1478,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();

View File

@@ -84,6 +84,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