Make sure to clear previous display's last focus window when reparenting task

This CL is to fix IME can't show up on reparented task in auto device with per-display
focus enabled.

When reparenting task from display A to display B, if the current display focus from
display of the task changed to another display (i.e. received a pointer outside touch),

It made in DisplayContent#reParentWindowToken logic won't clear prevDc#mLastFocus
(the reparent task's window in previous display), since mCurrentFocus
(the target display's window) is not the same as prevDc#mLastFocus during reparent,
caused the client side will end up receive window focus lost change (this issue won't
happen w/o per-display focus, since prevDc#mLastFocus will always null due to only
single focus window), so IME can't show up when tapping the EditText of the reparented
task.

The fix is to consolide clear prevDc#mLastFocus check, if last focused window of
previous display is contained in a reparented window token, which means
the reparent task will end up to gain window focus on the target display & won't need to
receive focus lost event from previous display & the state should be cleared.

Bug: 136503036
Test: atest MultiDisplaySystemDecorationTests#testImeWindowCanShownWhenActivityMovedToDisplay
Change-Id: Ifd5b7bbf381440c302194c9efff595bf51b5b42b
This commit is contained in:
lumark
2019-09-09 09:47:22 +08:00
parent 8a91775d3f
commit 280cb21137

View File

@@ -1072,9 +1072,10 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo
// removing from parent.
token.getParent().removeChild(token);
}
if (prevDc.mLastFocus == mCurrentFocus) {
// The window has become the focus of this display, so it should not be notified
// that it lost focus from the previous display.
if (token.hasChild(prevDc.mLastFocus)) {
// If the reparent window token contains previous display's last focus window, means
// it will end up to gain window focus on the target display, so it should not be
// notified that it lost focus from the previous display.
prevDc.mLastFocus = null;
}
}