Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 78b080c7 authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Replace mSkipAnimationOnce with initiallyVisible in InsetsSourceControl" into main

parents ada9c0d0 c7f05add
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -1911,7 +1911,7 @@ public class InsetsController implements WindowInsetsController, InsetsAnimation
            @Nullable ImeTracker.Token statsToken) {
        // TODO(b/166736352): We should only skip the animation of specific types, not all types.
        boolean skipsAnim = false;
        if ((types & ime()) != 0) {
        if (!Flags.unifySkipAnimationOnceWithInitiallyVisible() && (types & ime()) != 0) {
            final InsetsSourceControl imeControl = mImeSourceConsumer.getControl();
            // Skip showing animation once that made by system for some reason.
            // (e.g. starting window with hasImeSurface)
+6 −0
Original line number Diff line number Diff line
@@ -221,3 +221,9 @@ flag {
  }
}

flag {
  name: "unify_skip_animation_once_with_initially_visible"
  namespace: "input_method"
  description: "Deprecating skipAnimationOnce and using initiallyVisible instead."
  bug: "440511879"
}
+41 −1
Original line number Diff line number Diff line
@@ -211,12 +211,52 @@ final class ImeInsetsSourceProvider extends InsetsSourceProvider {
        return isSurfaceVisible;
    }

    @Override
    protected boolean isInitiallyVisible(@NonNull InsetsControlTarget target) {
        boolean initiallyVisible = super.isInitiallyVisible(target);
        // parent initiallyVisible is true, if it is client visible.
        if (initiallyVisible && mServerVisible) {
            WindowContainer<?> imeParentWindow = mDisplayContent.getImeParentWindow();
            // If the IME is attached to an app window, only consider it initially visible
            // if the parent is visible and wasn't part of a transition.
            initiallyVisible =
                    imeParentWindow != null && !imeParentWindow.inTransition()
                            && imeParentWindow.isVisible()
                            && imeParentWindow.isVisibleRequested();
        } else {
            initiallyVisible = false;
        }
        if (android.view.inputmethod.Flags.unifySkipAnimationOnceWithInitiallyVisible()
                && !initiallyVisible && target.getWindow() != null) {
            final var targetWin = target.getWindow();
            final Task task = targetWin.getTask();
            // If the control target has a starting window, and its snapshot was captured while
            // the IME was visible, skip the next IME show animation on the IME source control,
            // to gracefully restore the IME visibility.
            StartingData startingData = null;
            if (task != null) {
                startingData = targetWin.mActivityRecord.mStartingData;
                if (startingData == null) {
                    final WindowState startingWin = task.topStartingWindow();
                    if (startingWin != null) {
                        startingData = startingWin.mStartingData;
                    }
                }
                initiallyVisible = startingData != null && startingData.hasImeSurface();
                ProtoLog.d(WM_DEBUG_IME, "Overwriting initiallyVisible %s for %s",
                        initiallyVisible, targetWin);
            }
        }
        return initiallyVisible;
    }

    @Nullable
    @Override
    InsetsSourceControl getControl(@NonNull InsetsControlTarget target) {
        final InsetsSourceControl control = super.getControl(target);
        final WindowState targetWin = target.getWindow();
        if (control != null && targetWin != null) {
        if (!android.view.inputmethod.Flags.unifySkipAnimationOnceWithInitiallyVisible()
                && control != null && targetWin != null) {
            final Task task = targetWin.getTask();
            // If the control target has a starting window, and its snapshot was captured while
            // the IME was visible, skip the next IME show animation on the IME source control,
+9 −12
Original line number Diff line number Diff line
@@ -195,6 +195,14 @@ class InsetsSourceProvider {
        return mWin != null && mWin.wouldBeVisibleIfPolicyIgnored() && mWin.isVisibleByPolicy();
    }

    /**
     * @param target the current control target.
     * @return whether the {@link InsetsSourceControl} should be initially visible.
     */
    protected boolean isInitiallyVisible(@NonNull InsetsControlTarget target) {
        return mClientVisible;
    }

    /**
     * Updates the window that currently backs this source.
     *
@@ -504,22 +512,11 @@ class InsetsSourceProvider {
            // will be changed earlier than expected, which can cause flicker.
            return;
        }
        boolean initiallyVisible = mClientVisible;
        final Point surfacePosition = getWindowFrameSurfacePosition(mWin);
        mPosition.set(surfacePosition);
        mAdapter = new ControlAdapter(surfacePosition);
        final boolean initiallyVisible = isInitiallyVisible(target);
        if (mSource.getType() == WindowInsets.Type.ime()) {
            if (mClientVisible && mServerVisible) {
                WindowContainer imeParentWindow = mDisplayContent.getImeParentWindow();
                // If the IME is attached to an app window, only consider it initially visible
                // if the parent is visible and wasn't part of a transition.
                initiallyVisible =
                        imeParentWindow != null && !imeParentWindow.inTransition()
                                && imeParentWindow.isVisible()
                                && imeParentWindow.isVisibleRequested();
            } else {
                initiallyVisible = false;
            }
            setClientVisible(target.isRequestedVisible(WindowInsets.Type.ime()));
        }
        final Transaction t = mWin.getSyncTransaction();