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

Changes includes:
- In DC#computeImeTarget, 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.
- Screenshot Task with IME window if IME is attatched to the app.
- Ignore hiding current IME if IME is attached to the app.

Bug: 166736352
Test: manual, test the app with focusing editor and show soft-input,
      swiping up recents and see if the task view with IME screenshot are
      shows up without flickering.

Change-Id: Ib898bc2e3a5b063fe9eaf8b07d022231dd1326a3
This commit is contained in:
Ming-Shin Lu
2020-09-14 00:07:04 +08:00
parent 897df7e3ca
commit 60222bf60d
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 {