summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIonut Hulub <ionut.hulub@microsoft.com>2022-03-16 18:23:20 +0200
committerChris Li <lihongyu@google.com>2022-03-21 16:16:20 +0800
commit8bda50023d44836da07ddbf12b65be7b28c87f09 (patch)
treeb4e8143222aa897c2da9539e034bbec6424efd37
parent2907ec82abf8639cf0226bdd3eb56afa43c908d3 (diff)
Reparent ImeContainer under parent when organized.
If, for whatever reason, the SystemUI process crashed and restarted, the IME wasn't functional anymore (it would not become visible). That happened because, after the SystemUI crash, the IME was unorganized for a while and the framework reparented its surface under an activity. With this commit we fix this issue by reparenting the IME under its parent when it becomes organized again. Manual Test: Checked that the IME becomes visible after a systemui crash. Test: atest DisplayContentTests #testImeContainerIsReparentedUnderParentWhenOrganized Bug: 224800157 Change-Id: I303baf96c905a9c4b444189b731f63c7d51a11f2 Change-Id: I4d2934516e528bf353395e1759f59612542bdb56
-rw-r--r--data/etc/services.core.protolog.json18
-rw-r--r--services/core/java/com/android/server/wm/DisplayContent.java17
-rw-r--r--services/tests/wmtests/src/com/android/server/wm/DisplayContentTests.java27
3 files changed, 56 insertions, 6 deletions
diff --git a/data/etc/services.core.protolog.json b/data/etc/services.core.protolog.json
index 4449c48d28bb..10459ca69d61 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 736732029510..b55fdeeaccb7 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 40b460157bc2..9c5debf3a3c1 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.