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

Commit 20ccece6 authored by Tiger Huang's avatar Tiger Huang Committed by Android (Google) Code Review
Browse files

Merge "Notify the host when the insets animation running state is changed" into main

parents 3c941e1a 0de0a5fa
Loading
Loading
Loading
Loading
+17 −0
Original line number Diff line number Diff line
@@ -216,6 +216,14 @@ public class InsetsController implements WindowInsetsController, InsetsAnimation
        default CompatibilityInfo.Translator getTranslator() {
            return null;
        }

        /**
         * Notifies when the state of running animation is changed. The state is either "running" or
         * "idle".
         *
         * @param running {@code true} if there is any animation running; {@code false} otherwise.
         */
        default void notifyAnimationRunningStateChanged(boolean running) {}
    }

    private static final String TAG = "InsetsController";
@@ -749,6 +757,9 @@ public class InsetsController implements WindowInsetsController, InsetsAnimation
                    final InsetsAnimationControlRunner runner = new InsetsResizeAnimationRunner(
                            mFrame, state1, mToState, RESIZE_INTERPOLATOR,
                            ANIMATION_DURATION_RESIZE, mTypes, InsetsController.this);
                    if (mRunningAnimations.isEmpty()) {
                        mHost.notifyAnimationRunningStateChanged(true);
                    }
                    mRunningAnimations.add(new RunningAnimation(runner, runner.getAnimationType()));
                }
            };
@@ -1382,6 +1393,9 @@ public class InsetsController implements WindowInsetsController, InsetsAnimation
            }
        }
        ImeTracker.forLogging().onProgress(statsToken, ImeTracker.PHASE_CLIENT_ANIMATION_RUNNING);
        if (mRunningAnimations.isEmpty()) {
            mHost.notifyAnimationRunningStateChanged(true);
        }
        mRunningAnimations.add(new RunningAnimation(runner, animationType));
        if (DEBUG) Log.d(TAG, "Animation added to runner. useInsetsAnimationThread: "
                + useInsetsAnimationThread);
@@ -1588,6 +1602,9 @@ public class InsetsController implements WindowInsetsController, InsetsAnimation
                break;
            }
        }
        if (mRunningAnimations.isEmpty()) {
            mHost.notifyAnimationRunningStateChanged(false);
        }
        onAnimationStateChanged(removedTypes, false /* running */);
    }

+6 −0
Original line number Diff line number Diff line
@@ -816,6 +816,8 @@ public final class ViewRootImpl implements ViewParent,
    private long mFpsPrevTime = -1;
    private int mFpsNumFrames;

    private boolean mInsetsAnimationRunning;

    /**
     * The resolved pointer icon type requested by this window.
     * A null value indicates the resolved pointer icon has not yet been calculated.
@@ -2179,6 +2181,10 @@ public final class ViewRootImpl implements ViewParent,
        }
    }

    void notifyInsetsAnimationRunningStateChanged(boolean running) {
        mInsetsAnimationRunning = running;
    }

    @Override
    public void requestLayout() {
        if (!mHandlingLayoutInLayoutRequest) {
+7 −0
Original line number Diff line number Diff line
@@ -279,6 +279,13 @@ public class ViewRootInsetsControllerHost implements InsetsController.Host {
        return null;
    }

    @Override
    public void notifyAnimationRunningStateChanged(boolean running) {
        if (mViewRoot != null) {
            mViewRoot.notifyInsetsAnimationRunningStateChanged(running);
        }
    }

    private boolean isVisibleToUser() {
        return mViewRoot.getHostVisibility() == View.VISIBLE;
    }
+7 −0
Original line number Diff line number Diff line
@@ -740,6 +740,8 @@ class InsetsPolicy {
        private final Handler mHandler;
        private final String mName;

        private boolean mInsetsAnimationRunning;

        Host(Handler handler, String name) {
            mHandler = handler;
            mName = name;
@@ -841,5 +843,10 @@ class InsetsPolicy {
        public IBinder getWindowToken() {
            return null;
        }

        @Override
        public void notifyAnimationRunningStateChanged(boolean running) {
            mInsetsAnimationRunning = running;
        }
    }
}