Merge "Better IME transition while switching app with recents (1/N)"

This commit is contained in:
Ming-Shin Lu
2020-10-07 13:23:18 +00:00
committed by Android (Google) Code Review
3 changed files with 25 additions and 2 deletions

View File

@@ -3374,6 +3374,14 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp
mUpdateImeTarget = updateImeTarget;
WindowState target = getWindow(mComputeImeTargetPredicate);
// Keeps the IME target with the last window while swiping up to recents to prevent
// flickering due to IME hide animation on top of recents.
// TODO(b/166736352): This logic should go away once we switch over target immediately
// and do the screenshot to preserve IME on disappearing target
if (target != null && curTarget != null && target.isActivityTypeHome()
&& curTarget.getInsetsState().getSource(ITYPE_IME).isVisible()) {
return curTarget;
}
// Yet more tricksyness! If this window is a "starting" window, we do actually want
// to be on top of it, but it is not -really- where input will go. So look down below
@@ -3546,7 +3554,7 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp
);
}
private void updateImeParent() {
void updateImeParent() {
final SurfaceControl newParent = computeImeParent();
if (newParent != null) {
getPendingTransaction().reparent(mImeWindowsContainers.mSurfaceControl, newParent);

View File

@@ -283,6 +283,20 @@ public class RecentsAnimationController implements DeathRecipient {
public void hideCurrentInputMethod() {
final long token = Binder.clearCallingIdentity();
try {
synchronized (mService.getWindowManagerLock()) {
// Make sure to update the correct IME parent in case that the IME parent may
// be computed as display layer when re-layout window happens during rotation
// but there is intermediate state that the bounds of task and the IME
// target's activity is not the same during rotating.
mDisplayContent.updateImeParent();
// Ignore hiding IME if IME window is attached to app.
// Since we would like to snapshot Task with IME window while transitioning
// to recents.
if (mDisplayContent.isImeAttachedToApp()) {
return;
}
}
final InputMethodManagerInternal inputMethodManagerInternal =
LocalServices.getService(InputMethodManagerInternal.class);
if (inputMethodManagerInternal != null) {

View File

@@ -368,7 +368,8 @@ class TaskSnapshotController {
SurfaceControl[] excludeLayers;
final WindowState imeWindow = task.getDisplayContent().mInputMethodWindow;
if (imeWindow != null) {
// Exclude IME window snapshot when IME isn't proper to attach to app.
if (imeWindow != null && !task.getDisplayContent().isImeAttachedToApp()) {
excludeLayers = new SurfaceControl[1];
excludeLayers[0] = imeWindow.getSurfaceControl();
} else {