Improve InsetsPolicy#adjustVisibilityForIme when switching apps
When switching tasks from the task has IME shown to another task
without showing IME (e.g. youtube apps.), the flickering might happen
because the next activity accidentally received the IME insets attached
in the previous activity.
If the IME is attached to one app window on that time, even the next
app window is behind the IME window, conceptually the window should
not receive the IME insets if the next window is not eligible IME
requester and ready to show IME on top of it.
Previously, we introduced CL with checking task animating state and
check if the window has request IME visiblity to judge if the next
focus window is eligible to get IME insets.
However, CL overlooked that some apps design may using a child
window to receive IME insets but not the IME requester (the requester
is activity main window), so makes the regression that the child window
may not able to receive IME to adjust editor layout on the main window
like Bug 195385541 and Bug 195846009.
As the result, in this CL we introduce another way to fix this improper
IME insets delivering.
The fix way is straight forward. when the task with showing IME is
leaving, we'll set a flag to froze IME insets state for all windows
until the next task's IME input target has focused and reprorted to
As this fix approach could be more simple and preversing the original
Refine the logic in InsetsPolicy#adjustVisibilityForIme with the above
Test: atest WindowStateTests#\
Test: atest ActivityRecordTests
Test: manual as below steps:
1) Switch tasks with the task has IME shown (e.g. Android Message)
and youtube apps.
2) Expect youtube no flickering when switched the task from
(cherry picked from commit 4950787a4313d8c0fa6685a9f3dbfb0b05671cf0)
6 files changed