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

Commit c2568d6c authored by Tiger Huang's avatar Tiger Huang
Browse files

Set mIsAnimationPending when the leash is not ready

The server might return a control without a leash to a client while the
setup-transaction of the leash has not been applied yet. If the client
tries to play the animation with the control, the animation won't take
effect.

This CL sets mIsAnimationPending while changing the requested visibility
while the leash of the real control (not the fake one in transient mode)
is not ready. So when the client receives the leash later, the animation
will be played.

Fix: 183362710
Test: steps in the bug
Change-Id: I53108bacf98ac76c3f1e46cdae0a98581bef77f5
parent 6c9640f8
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -1131,7 +1131,7 @@ public class InsetsController implements WindowInsetsController, InsetsAnimation
                continue;
            }
            final InsetsSourceControl control = consumer.getControl();
            if (control != null) {
            if (control != null && control.getLeash() != null) {
                controls.put(consumer.getType(), new InsetsSourceControl(control));
                typesReady |= toPublicType(consumer.getType());
            } else if (animationType == ANIMATION_TYPE_SHOW) {
+11 −5
Original line number Diff line number Diff line
@@ -33,6 +33,7 @@ import static com.android.internal.annotations.VisibleForTesting.Visibility.PACK

import android.annotation.IntDef;
import android.annotation.Nullable;
import android.graphics.Insets;
import android.graphics.Rect;
import android.util.Log;
import android.util.imetracing.ImeTracing;
@@ -240,10 +241,6 @@ public class InsetsSourceConsumer {
        mHasWindowFocus = false;
    }

    boolean hasWindowFocus() {
        return mHasWindowFocus;
    }

    boolean hasViewFocusWhenWindowFocusGain() {
        return mHasViewFocusWhenWindowFocusGain;
    }
@@ -366,7 +363,16 @@ public class InsetsSourceConsumer {
    protected void setRequestedVisible(boolean requestedVisible) {
        if (mRequestedVisible != requestedVisible) {
            mRequestedVisible = requestedVisible;
            mIsAnimationPending = false;

            // We need an animation later if the leash of a real control (which has an insets hint)
            // is not ready. The !mIsAnimationPending check is in case that the requested visibility
            // is changed twice before playing the animation -- we don't need an animation in this
            // case.
            mIsAnimationPending = !mIsAnimationPending
                    && mSourceControl != null
                    && mSourceControl.getLeash() == null
                    && !Insets.NONE.equals(mSourceControl.getInsetsHint());

            mController.onRequestedVisibilityChanged(this);
            if (DEBUG) Log.d(TAG, "setRequestedVisible: " + requestedVisible);
        }