From e80e94182cbde56dc0ff796edc2e248d85babeed Mon Sep 17 00:00:00 2001 From: Tiger Huang Date: Wed, 2 Sep 2020 00:02:17 +0800 Subject: Compare with oldSoftInputMode after restoring softInputMode ... of mWindowAttributes. Apps might update LayoutParams with softInputMode unspecified on applying insets, and this can cause infinite loop in the previous logic, because we would auto-compute softInputMode for the unspecified one, which makes app's softInputMode never be the same as the one in ViewRootImpl.mWindowAttributes. Fix: 163009478 Test: Print stack trace before calling requestFitSystemWindows() and follow the steps in the bug. Test: Open Messages, go to attachments, reopen IME Change-Id: I2341121b69209688c2f6fb033f51611b21422a04 --- core/java/android/view/ViewRootImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/java/android/view/ViewRootImpl.java b/core/java/android/view/ViewRootImpl.java index bcf3b49c6644..5c42408dab05 100644 --- a/core/java/android/view/ViewRootImpl.java +++ b/core/java/android/view/ViewRootImpl.java @@ -1456,7 +1456,7 @@ public final class ViewRootImpl implements ViewParent, | (oldSoftInputMode & WindowManager.LayoutParams.SOFT_INPUT_MASK_ADJUST); } - if ((changes & LayoutParams.SOFT_INPUT_MODE_CHANGED) != 0) { + if (mWindowAttributes.softInputMode != oldSoftInputMode) { requestFitSystemWindows(); } -- cgit v1.2.3-59-g8ed1b