diff --git a/data/etc/services.core.protolog.json b/data/etc/services.core.protolog.json index 4449c48d28bb2..10459ca69d618 100644 --- a/data/etc/services.core.protolog.json +++ b/data/etc/services.core.protolog.json @@ -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", diff --git a/services/core/java/com/android/server/wm/DisplayContent.java b/services/core/java/com/android/server/wm/DisplayContent.java index 7367320295104..b55fdeeaccb71 100644 --- a/services/core/java/com/android/server/wm/DisplayContent.java +++ b/services/core/java/com/android/server/wm/DisplayContent.java @@ -4877,6 +4877,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); + } + } } } diff --git a/services/tests/wmtests/src/com/android/server/wm/DisplayContentTests.java b/services/tests/wmtests/src/com/android/server/wm/DisplayContentTests.java index 40b460157bc29..9c5debf3a3c16 100644 --- a/services/tests/wmtests/src/com/android/server/wm/DisplayContentTests.java +++ b/services/tests/wmtests/src/com/android/server/wm/DisplayContentTests.java @@ -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.