Merge "Reparent ImeContainer under parent when organized." into tm-dev

This commit is contained in:
Chris Li 2022-03-22 07:32:39 +00:00 committed by Android (Google) Code Review
commit 6cc0fa4d00
3 changed files with 56 additions and 6 deletions

View File

@ -1927,6 +1927,12 @@
"group": "WM_SHOW_TRANSACTIONS",
"at": "com\/android\/server\/wm\/Session.java"
},
"-81121442": {
"message": "ImeContainer just became organized but it doesn't have a parent or the parent doesn't have a surface control. mSurfaceControl=%s imeParentSurfaceControl=%s",
"level": "ERROR",
"group": "WM_DEBUG_IME",
"at": "com\/android\/server\/wm\/DisplayContent.java"
},
"-80004683": {
"message": "Resume failed; resetting state to %s: %s",
"level": "VERBOSE",
@ -2767,12 +2773,6 @@
"group": "WM_DEBUG_WALLPAPER",
"at": "com\/android\/server\/wm\/WallpaperWindowToken.java"
},
"736003885": {
"message": "Unable to retrieve the task token to start recording for display %d",
"level": "VERBOSE",
"group": "WM_DEBUG_CONTENT_RECORDING",
"at": "com\/android\/server\/wm\/ContentRecorder.java"
},
"736692676": {
"message": "Config is relaunching %s",
"level": "VERBOSE",
@ -3139,6 +3139,12 @@
"group": "WM_DEBUG_BACK_PREVIEW",
"at": "com\/android\/server\/wm\/BackNavigationController.java"
},
"1175495463": {
"message": "ImeContainer just became organized. Reparenting under parent. imeParentSurfaceControl=%s",
"level": "INFO",
"group": "WM_DEBUG_IME",
"at": "com\/android\/server\/wm\/DisplayContent.java"
},
"1178653181": {
"message": "Old wallpaper still the target.",
"level": "VERBOSE",

View File

@ -4875,6 +4875,23 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp
void setOrganizer(IDisplayAreaOrganizer organizer, boolean skipDisplayAreaAppeared) {
super.setOrganizer(organizer, skipDisplayAreaAppeared);
mDisplayContent.updateImeParent();
// If the ImeContainer was previously unorganized then the framework might have
// reparented its surface control under an activity so we need to reparent it back
// under its parent.
if (organizer != null) {
final SurfaceControl imeParentSurfaceControl = getParentSurfaceControl();
if (mSurfaceControl != null && imeParentSurfaceControl != null) {
ProtoLog.i(WM_DEBUG_IME, "ImeContainer just became organized. Reparenting "
+ "under parent. imeParentSurfaceControl=%s", imeParentSurfaceControl);
getPendingTransaction().reparent(mSurfaceControl, imeParentSurfaceControl);
} else {
ProtoLog.e(WM_DEBUG_IME, "ImeContainer just became organized but it doesn't "
+ "have a parent or the parent doesn't have a surface control."
+ " mSurfaceControl=%s imeParentSurfaceControl=%s",
mSurfaceControl, imeParentSurfaceControl);
}
}
}
}

View File

@ -414,6 +414,33 @@ public class DisplayContentTests extends WindowTestsBase {
imeContainer.setOrganizer(null);
}
@Test
public void testImeContainerIsReparentedUnderParentWhenOrganized() {
final DisplayArea.Tokens imeContainer = mDisplayContent.getImeContainer();
final ActivityRecord activity = createActivityRecord(mDisplayContent);
final WindowState startingWin = createWindow(null, TYPE_APPLICATION_STARTING, activity,
"startingWin");
startingWin.setHasSurface(true);
assertTrue(startingWin.canBeImeTarget());
final Transaction transaction = mDisplayContent.getPendingTransaction();
spyOn(transaction);
// Organized the ime container.
final IDisplayAreaOrganizer mockImeOrganizer = mock(IDisplayAreaOrganizer.class);
when(mockImeOrganizer.asBinder()).thenReturn(new Binder());
imeContainer.setOrganizer(mockImeOrganizer);
// Verify that the ime container surface is reparented under
// its parent surface as a consequence of the setOrganizer call.
SurfaceControl imeParentSurfaceControl = imeContainer.getParentSurfaceControl();
verify(transaction).reparent(imeContainer.getSurfaceControl(), imeParentSurfaceControl);
// Clean up organizer.
imeContainer.setOrganizer(null);
}
/**
* This tests root task movement between displays and proper root task's, task's and app token's
* display container references updates.