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

Commit a1bacb09 authored by Felix Stern's avatar Felix Stern Committed by Android (Google) Code Review
Browse files

Merge "Sending requested IME visibility at the beginning of the hide animation" into main

parents db608e9e 6b8d5ef2
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -1986,7 +1986,11 @@ public class InsetsController implements WindowInsetsController, InsetsAnimation
            // report its requested visibility at the end of the animation, otherwise we would
            // lose the leash, and it would disappear during the animation
            // TODO(b/326377046) revisit this part and see if we can make it more general
            if (Flags.reportAnimatingInsetsTypes()) {
                typesToReport = mRequestedVisibleTypes;
            } else {
                typesToReport = mRequestedVisibleTypes | (mAnimatingTypes & ime());
            }
        } else {
            typesToReport = mRequestedVisibleTypes;
        }
+14 −7
Original line number Diff line number Diff line
@@ -440,11 +440,18 @@ public class DisplayImeController implements DisplayController.OnDisplaysChanged
                            statsToken);
                }

                boolean hideAnimOngoing;
                boolean reportVisible;
                if (android.view.inputmethod.Flags.reportAnimatingInsetsTypes()) {
                    hideAnimOngoing = false;
                    reportVisible = mImeRequestedVisible;
                } else {
                    // In case of a hide, the statsToken should not been send yet (as the animation
                // is still ongoing). It will be sent at the end of the animation
                boolean hideAnimOngoing = !mImeRequestedVisible && mAnimation != null;
                setVisibleDirectly(mImeRequestedVisible || mAnimation != null,
                        hideAnimOngoing ? null : statsToken);
                    // is still ongoing). It will be sent at the end of the animation.
                    hideAnimOngoing = !mImeRequestedVisible && mAnimation != null;
                    reportVisible = mImeRequestedVisible || mAnimation != null;
                }
                setVisibleDirectly(reportVisible, hideAnimOngoing ? null : statsToken);
            }
        }

@@ -628,7 +635,7 @@ public class DisplayImeController implements DisplayController.OnDisplaysChanged
                                + " showing:" + (mAnimationDirection == DIRECTION_SHOW));
                    }
                    if (android.view.inputmethod.Flags.reportAnimatingInsetsTypes()) {
                        setAnimating(true);
                        setAnimating(true /* imeAnimationOngoing */);
                    }
                    int flags = dispatchStartPositioning(mDisplayId, imeTop(hiddenY, defaultY),
                            imeTop(shownY, defaultY), mAnimationDirection == DIRECTION_SHOW,
@@ -678,7 +685,7 @@ public class DisplayImeController implements DisplayController.OnDisplaysChanged
                    if (!android.view.inputmethod.Flags.refactorInsetsController()) {
                        dispatchEndPositioning(mDisplayId, mCancelled, t);
                    } else if (android.view.inputmethod.Flags.reportAnimatingInsetsTypes()) {
                        setAnimating(false);
                        setAnimating(false /* imeAnimationOngoing */);
                    }
                    if (mAnimationDirection == DIRECTION_HIDE && !mCancelled) {
                        ImeTracker.forLogging().onProgress(mStatsToken,
+4 −0
Original line number Diff line number Diff line
@@ -7104,6 +7104,10 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp
        public void setAnimatingTypes(@InsetsType int animatingTypes) {
            if (mAnimatingTypes != animatingTypes) {
                mAnimatingTypes = animatingTypes;

                if (android.view.inputmethod.Flags.reportAnimatingInsetsTypes()) {
                    getInsetsStateController().onAnimatingTypesChanged(this);
                }
            }
        }
    }
+25 −7
Original line number Diff line number Diff line
@@ -332,8 +332,7 @@ final class ImeInsetsSourceProvider extends InsetsSourceProvider {
            if (changed) {
                ImeTracker.forLogging().onProgress(statsToken,
                        ImeTracker.PHASE_SERVER_UPDATE_CLIENT_VISIBILITY);
                invokeOnImeRequestedChangedListener(mDisplayContent.getImeInputTarget(),
                        statsToken);
                invokeOnImeRequestedChangedListener(controlTarget, statsToken);
            } else {
                // TODO(b/353463205) check cancelled / failed
                ImeTracker.forLogging().onCancelled(statsToken,
@@ -387,7 +386,8 @@ final class ImeInsetsSourceProvider extends InsetsSourceProvider {
                // not all virtual displays have an ImeInsetsSourceProvider, so it is not
                // guaranteed that the IME will be started when the control target reports its
                // requested visibility back. Thus, invoking the listener here.
                invokeOnImeRequestedChangedListener(imeInsetsTarget, statsToken);
                invokeOnImeRequestedChangedListener((InsetsControlTarget) imeInsetsTarget,
                        statsToken);
            } else {
                ImeTracker.forLogging().onFailed(statsToken,
                        ImeTracker.PHASE_WM_SET_REMOTE_TARGET_IME_VISIBILITY);
@@ -396,18 +396,21 @@ final class ImeInsetsSourceProvider extends InsetsSourceProvider {
    }

    // TODO(b/353463205) check callers to see if we can make statsToken @NonNull
    private void invokeOnImeRequestedChangedListener(InsetsTarget insetsTarget,
    private void invokeOnImeRequestedChangedListener(InsetsControlTarget controlTarget,
            @Nullable ImeTracker.Token statsToken) {
        final var imeListener = mDisplayContent.mWmService.mOnImeRequestedChangedListener;
        if (imeListener != null) {
            if (insetsTarget != null) {
            if (controlTarget != null) {
                final boolean imeAnimating = Flags.reportAnimatingInsetsTypes()
                        && (controlTarget.getAnimatingTypes() & WindowInsets.Type.ime()) != 0;
                ImeTracker.forLogging().onProgress(statsToken,
                        ImeTracker.PHASE_WM_POSTING_CHANGED_IME_VISIBILITY);
                mDisplayContent.mWmService.mH.post(() -> {
                    ImeTracker.forLogging().onProgress(statsToken,
                            ImeTracker.PHASE_WM_INVOKING_IME_REQUESTED_LISTENER);
                    imeListener.onImeRequestedChanged(insetsTarget.getWindowToken(),
                            insetsTarget.isRequestedVisible(WindowInsets.Type.ime()), statsToken);
                    imeListener.onImeRequestedChanged(controlTarget.getWindowToken(),
                            controlTarget.isRequestedVisible(WindowInsets.Type.ime())
                                    || imeAnimating, statsToken);
                });
            } else {
                ImeTracker.forLogging().onFailed(statsToken,
@@ -420,6 +423,21 @@ final class ImeInsetsSourceProvider extends InsetsSourceProvider {
        }
    }

    @Override
    void onAnimatingTypesChanged(InsetsControlTarget caller) {
        if (Flags.reportAnimatingInsetsTypes()) {
            final InsetsControlTarget controlTarget = getControlTarget();
            // If the IME is not being requested anymore and the animation is finished, we need to
            // invoke the listener, to let IMS eventually know
            if (caller != null && caller == controlTarget && !caller.isRequestedVisible(
                    WindowInsets.Type.ime())
                    && (caller.getAnimatingTypes() & WindowInsets.Type.ime()) == 0) {
                // TODO(b/353463205) check statsToken
                invokeOnImeRequestedChangedListener(caller, null);
            }
        }
    }

    private void reportImeDrawnForOrganizerIfNeeded(@NonNull InsetsControlTarget caller) {
        final WindowState callerWindow = caller.getWindow();
        if (callerWindow == null) {
+3 −0
Original line number Diff line number Diff line
@@ -673,6 +673,9 @@ class InsetsSourceProvider {
                mServerVisible, mClientVisible);
    }

    void onAnimatingTypesChanged(InsetsControlTarget caller) {
    }

    protected boolean isLeashReadyForDispatching() {
        return isLeashInitialized();
    }
Loading