Merge "[wm] Use existing parent window token for child windows" into rvc-qpr-dev am: e966c47691

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/12629525

Change-Id: I4996b3ea59155d46357bb0443a7db1f9247afe33
This commit is contained in:
Wei Sheng Shih
2020-09-22 03:00:36 +00:00
committed by Automerger Merge Worker
2 changed files with 12 additions and 3 deletions

View File

@@ -1476,9 +1476,14 @@ public class WindowManagerService extends IWindowManager.Stub
rootType, attrs.token, attrs.packageName)) { rootType, attrs.token, attrs.packageName)) {
return WindowManagerGlobal.ADD_BAD_APP_TOKEN; return WindowManagerGlobal.ADD_BAD_APP_TOKEN;
} }
if (hasParent) {
// Use existing parent window token for child windows.
token = parentWindow.mToken;
} else {
final IBinder binder = attrs.token != null ? attrs.token : client.asBinder(); final IBinder binder = attrs.token != null ? attrs.token : client.asBinder();
token = new WindowToken(this, binder, type, false, displayContent, token = new WindowToken(this, binder, type, false, displayContent,
session.mCanAddInternalSystemWindow, isRoundedCornerOverlay); session.mCanAddInternalSystemWindow, isRoundedCornerOverlay);
}
} else if (rootType >= FIRST_APPLICATION_WINDOW } else if (rootType >= FIRST_APPLICATION_WINDOW
&& rootType <= LAST_APPLICATION_WINDOW) { && rootType <= LAST_APPLICATION_WINDOW) {
activity = token.asActivityRecord(); activity = token.asActivityRecord();

View File

@@ -78,6 +78,10 @@ public class WindowTokenTests extends WindowTestsBase {
assertFalse(token.hasWindow(window12)); assertFalse(token.hasWindow(window12));
assertTrue(token.hasWindow(window2)); assertTrue(token.hasWindow(window2));
assertTrue(token.hasWindow(window3)); 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 @Test