Loading core/java/android/view/InsetsAnimationControlCallbacks.java +12 −8 Original line number Diff line number Diff line Loading @@ -16,12 +16,14 @@ package android.view; import android.annotation.NonNull; import android.view.WindowInsets.Type.InsetsType; import android.view.WindowInsetsAnimation.Bounds; /** * Provide an interface to let InsetsAnimationControlImpl and InsetsResizeAnimationRunner call back * into its owner. * * @hide */ public interface InsetsAnimationControlCallbacks { Loading @@ -36,33 +38,35 @@ public interface InsetsAnimationControlCallbacks { * </ul> */ <T extends InsetsAnimationControlRunner & InternalInsetsAnimationController> void startAnimation(T runner, WindowInsetsAnimationControlListener listener, int types, WindowInsetsAnimation animation, Bounds bounds); void startAnimation(@NonNull T runner, @NonNull WindowInsetsAnimationControlListener listener, @InsetsType int types, @NonNull WindowInsetsAnimation animation, @NonNull Bounds bounds); /** * Schedule the apply by posting the animation callback. * * @param runner The runner that requested applying insets */ void scheduleApplyChangeInsets(InsetsAnimationControlRunner runner); void scheduleApplyChangeInsets(@NonNull InsetsAnimationControlRunner runner); /** * Finish the final steps after the animation. * * @param runner The runner used to run the animation. * @param shown {@code true} if the insets are shown. */ void notifyFinished(InsetsAnimationControlRunner runner, boolean shown); void notifyFinished(@NonNull InsetsAnimationControlRunner runner, boolean shown); /** * Post a message to release the Surface, guaranteed to happen after all * previous calls to applySurfaceParams. */ void releaseSurfaceControlFromRt(SurfaceControl sc); void releaseSurfaceControlFromRt(@NonNull SurfaceControl sc); /** * Reports that the perceptibility of the given types has changed to the given value. * * A type is perceptible if it is not (almost) entirely off-screen and not (almost) entirely * <p>A type is perceptible if it is not (almost) entirely off-screen and not (almost) entirely * transparent. * * @param types the (public) types whose perceptibility has changed Loading core/java/android/view/InsetsAnimationControlImpl.java +92 −45 Original line number Diff line number Diff line Loading @@ -46,6 +46,8 @@ import static android.view.inputmethod.ImeTracker.DEBUG_IME_VISIBILITY; import static com.android.internal.annotations.VisibleForTesting.Visibility.PACKAGE; import android.annotation.FloatRange; import android.annotation.NonNull; import android.annotation.Nullable; import android.content.res.CompatibilityInfo; import android.graphics.Insets; Loading @@ -69,10 +71,12 @@ import android.view.inputmethod.ImeTracker; import com.android.internal.annotations.VisibleForTesting; import java.util.ArrayList; import java.util.List; import java.util.Objects; /** * Implements {@link WindowInsetsAnimationController} * * @hide */ @VisibleForTesting(visibility = VisibleForTesting.Visibility.PACKAGE) Loading @@ -81,55 +85,77 @@ public class InsetsAnimationControlImpl implements InternalInsetsAnimationContro private static final String TAG = "InsetsAnimationCtrlImpl"; @NonNull private final Rect mTmpFrame = new Rect(); @NonNull private final WindowInsetsAnimationControlListener mListener; @NonNull private final SparseArray<InsetsSourceControl> mControls; @NonNull private final SparseSetArray<InsetsSourceControl> mSideControlsMap = new SparseSetArray<>(); /** @see WindowInsetsAnimationController#getHiddenStateInsets */ @NonNull private final Insets mHiddenInsets; /** @see WindowInsetsAnimationController#getShownStateInsets */ @NonNull private final Insets mShownInsets; @NonNull private final Matrix mTmpMatrix = new Matrix(); @NonNull private final InsetsState mInitialInsetsState; private final @AnimationType int mAnimationType; private @LayoutInsetsDuringAnimation int mLayoutInsetsDuringAnimation; private final @InsetsType int mTypes; private @InsetsType int mControllingTypes; @AnimationType private final int mAnimationType; @LayoutInsetsDuringAnimation private int mLayoutInsetsDuringAnimation; @InsetsType private final int mTypes; @InsetsType private int mControllingTypes; @NonNull private final InsetsAnimationControlCallbacks mController; @NonNull private final SurfaceParamsApplier mSurfaceParamsApplier; @NonNull private final WindowInsetsAnimation mAnimation; private final long mDurationMs; private final Interpolator mInterpolator; /** @see WindowInsetsAnimationController#hasZeroInsetsIme */ private final boolean mHasZeroInsetsIme; @Nullable private final CompatibilityInfo.Translator mTranslator; @Nullable private final ImeTracker.Token mStatsToken; @NonNull private Insets mCurrentInsets; @NonNull private Insets mPendingInsets; @FloatRange(from = 0f, to = 1f) private float mPendingFraction; private boolean mFinished; private boolean mCancelling; private boolean mCancelled; private boolean mShownOnFinish; @FloatRange(from = 0f, to = 1f) private float mCurrentAlpha = 1.0f; @FloatRange(from = 0f, to = 1f) private float mPendingAlpha = 1.0f; @VisibleForTesting(visibility = PACKAGE) private boolean mReadyDispatched; @Nullable private Boolean mPerceptible; @VisibleForTesting(visibility = PACKAGE) public InsetsAnimationControlImpl(SparseArray<InsetsSourceControl> controls, @Nullable Rect frame, @Nullable Rect bounds, InsetsState state, WindowInsetsAnimationControlListener listener, @InsetsType int types, InsetsAnimationControlCallbacks controller, SurfaceParamsApplier surfaceParamsApplier, InsetsAnimationSpec insetsAnimationSpec, @AnimationType int animationType, public InsetsAnimationControlImpl(@NonNull SparseArray<InsetsSourceControl> controls, @Nullable Rect frame, @Nullable Rect bounds, @NonNull InsetsState state, @NonNull WindowInsetsAnimationControlListener listener, @InsetsType int types, @NonNull InsetsAnimationControlCallbacks controller, @NonNull SurfaceParamsApplier surfaceParamsApplier, @NonNull InsetsAnimationSpec insetsAnimationSpec, @AnimationType int animationType, @LayoutInsetsDuringAnimation int layoutInsetsDuringAnimation, CompatibilityInfo.Translator translator, @Nullable ImeTracker.Token statsToken) { @Nullable CompatibilityInfo.Translator translator, @Nullable ImeTracker.Token statsToken) { mControls = controls; mListener = listener; mTypes = types; Loading Loading @@ -182,7 +208,7 @@ public class InsetsAnimationControlImpl implements InternalInsetsAnimationContro new Bounds(mHiddenInsets, mShownInsets)); } private boolean calculatePerceptible(Insets currentInsets, float currentAlpha) { private boolean calculatePerceptible(@NonNull Insets currentInsets, float currentAlpha) { return 100 * currentInsets.left >= 5 * (mShownInsets.left - mHiddenInsets.left) && 100 * currentInsets.top >= 5 * (mShownInsets.top - mHiddenInsets.top) && 100 * currentInsets.right >= 5 * (mShownInsets.right - mHiddenInsets.right) Loading Loading @@ -211,27 +237,32 @@ public class InsetsAnimationControlImpl implements InternalInsetsAnimationContro } @Override @NonNull public Insets getHiddenStateInsets() { return mHiddenInsets; } @Override @NonNull public Insets getShownStateInsets() { return mShownInsets; } @Override @NonNull public Insets getCurrentInsets() { return mCurrentInsets; } @Override @FloatRange(from = 0f, to = 1f) public float getCurrentAlpha() { return mCurrentAlpha; } @Override @InsetsType public int getTypes() { @InsetsType public int getTypes() { return mTypes; } Loading @@ -246,7 +277,7 @@ public class InsetsAnimationControlImpl implements InternalInsetsAnimationContro } @Override public void updateSurfacePosition(SparseArray<InsetsSourceControl> controls) { public void updateSurfacePosition(@NonNull SparseArray<InsetsSourceControl> controls) { for (int i = controls.size() - 1; i >= 0; i--) { final InsetsSourceControl control = controls.valueAt(i); final InsetsSourceControl c = mControls.get(control.getId()); Loading @@ -264,11 +295,13 @@ public class InsetsAnimationControlImpl implements InternalInsetsAnimationContro } @Override public @AnimationType int getAnimationType() { @AnimationType public int getAnimationType() { return mAnimationType; } @Override @NonNull public SurfaceParamsApplier getSurfaceParamsApplier() { return mSurfaceParamsApplier; } Loading @@ -280,12 +313,15 @@ public class InsetsAnimationControlImpl implements InternalInsetsAnimationContro } @Override public void setInsetsAndAlpha(Insets insets, float alpha, float fraction) { public void setInsetsAndAlpha(@Nullable Insets insets, @FloatRange(from = 0f, to = 1f) float alpha, @FloatRange(from = 0f, to = 1f) float fraction) { setInsetsAndAlpha(insets, alpha, fraction, false /* allowWhenFinished */); } private void setInsetsAndAlpha(Insets insets, float alpha, float fraction, boolean allowWhenFinished) { private void setInsetsAndAlpha(@Nullable Insets insets, @FloatRange(from = 0f, to = 1f) float alpha, @FloatRange(from = 0f, to = 1f) float fraction, boolean allowWhenFinished) { if (!allowWhenFinished && mFinished) { throw new IllegalStateException( "Can't change insets on an animation that is finished."); Loading @@ -308,28 +344,30 @@ public class InsetsAnimationControlImpl implements InternalInsetsAnimationContro /** * @return Whether the finish callback of this animation should be invoked. */ @VisibleForTesting @VisibleForTesting(visibility = VisibleForTesting.Visibility.PACKAGE) public boolean applyChangeInsets(@Nullable InsetsState outState) { if (mCancelled) { if (DEBUG) Log.d(TAG, "applyChangeInsets canceled"); return false; } final Insets offset = Insets.subtract(mShownInsets, mPendingInsets); final ArrayList<SurfaceParams> params = new ArrayList<>(); final var params = new ArrayList<SurfaceParams>(); updateLeashesForSide(SIDE_LEFT, offset.left, params, outState, mPendingAlpha); updateLeashesForSide(SIDE_TOP, offset.top, params, outState, mPendingAlpha); updateLeashesForSide(SIDE_RIGHT, offset.right, params, outState, mPendingAlpha); updateLeashesForSide(SIDE_BOTTOM, offset.bottom, params, outState, mPendingAlpha); mSurfaceParamsApplier.applySurfaceParams(params.toArray(new SurfaceParams[params.size()])); mSurfaceParamsApplier.applySurfaceParams(params.toArray(new SurfaceParams[0])); mCurrentInsets = mPendingInsets; mAnimation.setFraction(mPendingFraction); mCurrentAlpha = mPendingAlpha; mAnimation.setAlpha(mPendingAlpha); if (mFinished) { if (DEBUG) Log.d(TAG, String.format( "notifyFinished shown: %s, currentAlpha: %f, currentInsets: %s", mShownOnFinish, mCurrentAlpha, mCurrentInsets)); if (DEBUG) { Log.d(TAG, "notifyFinished shown: " + mShownOnFinish + ", currentAlpha: " + mCurrentAlpha + ", currentInsets: " + mCurrentInsets); } mController.notifyFinished(this, mShownOnFinish); releaseLeashes(); if (DEBUG) Log.d(TAG, "Animation finished abruptly."); Loading Loading @@ -367,6 +405,7 @@ public class InsetsAnimationControlImpl implements InternalInsetsAnimationContro @Override @VisibleForTesting @FloatRange(from = 0f, to = 1f) public float getCurrentFraction() { return mAnimation.getFraction(); } Loading Loading @@ -403,6 +442,7 @@ public class InsetsAnimationControlImpl implements InternalInsetsAnimationContro } @Override @NonNull public WindowInsetsAnimation getAnimation() { return mAnimation; } Loading @@ -414,7 +454,7 @@ public class InsetsAnimationControlImpl implements InternalInsetsAnimationContro } @Override public void dumpDebug(ProtoOutputStream proto, long fieldId) { public void dumpDebug(@NonNull ProtoOutputStream proto, long fieldId) { final long token = proto.start(fieldId); proto.write(IS_CANCELLED, mCancelled); proto.write(IS_FINISHED, mFinished); Loading @@ -427,12 +467,14 @@ public class InsetsAnimationControlImpl implements InternalInsetsAnimationContro proto.end(token); } @NonNull SparseArray<InsetsSourceControl> getControls() { return mControls; } private Insets getInsetsFromState(InsetsState state, Rect frame, Rect bounds, @Nullable @InternalInsetsSide SparseIntArray idSideMap) { @NonNull private Insets getInsetsFromState(@NonNull InsetsState state, @NonNull Rect frame, @NonNull Rect bounds, @Nullable @InternalInsetsSide SparseIntArray idSideMap) { return state.calculateInsets(frame, bounds, null /* ignoringVisibilityState */, false /* isScreenRound */, SOFT_INPUT_ADJUST_RESIZE /* legacySoftInputMode */, 0 /* legacyWindowFlags */, 0 /* legacySystemUiFlags */, TYPE_APPLICATION, Loading @@ -440,8 +482,9 @@ public class InsetsAnimationControlImpl implements InternalInsetsAnimationContro } /** Computes the insets relative to the given frame. */ private Insets calculateInsets(InsetsState state, Rect frame, Rect bounds, SparseArray<InsetsSourceControl> controls, boolean shown, @NonNull private Insets calculateInsets(@NonNull InsetsState state, @NonNull Rect frame, @NonNull Rect bounds, @NonNull SparseArray<InsetsSourceControl> controls, boolean shown, @Nullable @InternalInsetsSide SparseIntArray idSideMap) { for (int i = controls.size() - 1; i >= 0; i--) { final InsetsSourceControl control = controls.valueAt(i); Loading @@ -455,8 +498,9 @@ public class InsetsAnimationControlImpl implements InternalInsetsAnimationContro } /** Computes the insets from the insets hints of controls. */ private Insets calculateInsets(InsetsState state, SparseArray<InsetsSourceControl> controls, boolean shownOrCurrent) { @NonNull private Insets calculateInsets(@Nullable InsetsState state, @NonNull SparseArray<InsetsSourceControl> controls, boolean shownOrCurrent) { Insets insets = Insets.NONE; if (!shownOrCurrent) { return insets; Loading @@ -475,7 +519,8 @@ public class InsetsAnimationControlImpl implements InternalInsetsAnimationContro return insets; } private Insets sanitize(Insets insets) { @NonNull private Insets sanitize(@Nullable Insets insets) { if (insets == null) { insets = getCurrentInsets(); } Loading @@ -485,12 +530,14 @@ public class InsetsAnimationControlImpl implements InternalInsetsAnimationContro return Insets.max(Insets.min(insets, mShownInsets), mHiddenInsets); } private static float sanitize(float alpha) { @FloatRange(from = 0f, to = 1f) private static float sanitize(@FloatRange(from = 0f, to = 1f) float alpha) { return alpha >= 1 ? 1 : (alpha <= 0 ? 0 : alpha); } private void updateLeashesForSide(@InternalInsetsSide int side, int offset, ArrayList<SurfaceParams> surfaceParams, @Nullable InsetsState outState, float alpha) { @NonNull List<SurfaceParams> surfaceParams, @Nullable InsetsState outState, @FloatRange(from = 0f, to = 1f) float alpha) { final ArraySet<InsetsSourceControl> controls = mSideControlsMap.get(side); if (controls == null) { return; Loading Loading @@ -536,8 +583,8 @@ public class InsetsAnimationControlImpl implements InternalInsetsAnimationContro } } private void addTranslationToMatrix(@InternalInsetsSide int side, int offset, Matrix m, Rect frame) { private void addTranslationToMatrix(@InternalInsetsSide int side, int offset, @NonNull Matrix m, @NonNull Rect frame) { final float surfaceOffset = mTranslator != null ? mTranslator.translateLengthInAppWindowToScreen(offset) : offset; switch (side) { Loading @@ -560,9 +607,9 @@ public class InsetsAnimationControlImpl implements InternalInsetsAnimationContro } } private static void buildSideControlsMap(SparseIntArray idSideMap, SparseSetArray<InsetsSourceControl> sideControlsMap, SparseArray<InsetsSourceControl> controls) { private static void buildSideControlsMap(@NonNull SparseIntArray idSideMap, @NonNull SparseSetArray<InsetsSourceControl> sideControlsMap, @NonNull SparseArray<InsetsSourceControl> controls) { for (int i = idSideMap.size() - 1; i >= 0; i--) { final int type = idSideMap.keyAt(i); final int side = idSideMap.valueAt(i); Loading @@ -577,8 +624,8 @@ public class InsetsAnimationControlImpl implements InternalInsetsAnimationContro } private static void buildSideControlsMap( SparseSetArray<InsetsSourceControl> sideControlsMap, SparseArray<InsetsSourceControl> controls) { @NonNull SparseSetArray<InsetsSourceControl> sideControlsMap, @NonNull SparseArray<InsetsSourceControl> controls) { for (int i = controls.size() - 1; i >= 0; i--) { final InsetsSourceControl control = controls.valueAt(i); if (control == null) { Loading core/java/android/view/InsetsAnimationControlRunner.java +15 −10 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ package android.view; import android.annotation.NonNull; import android.annotation.Nullable; import android.util.SparseArray; import android.util.proto.ProtoOutputStream; Loading @@ -34,13 +35,15 @@ public interface InsetsAnimationControlRunner { /** * @return The {@link InsetsType} the animation of this runner controls. */ @InsetsType int getTypes(); @InsetsType int getTypes(); /** * @return The {@link InsetsType} the animation of this runner is controlling. This can be * changed if a control is revoked. */ @InsetsType int getControllingTypes(); @InsetsType int getControllingTypes(); /** * Notifies {@link InsetsType types} of control are getting revoked. Loading @@ -52,7 +55,7 @@ public interface InsetsAnimationControlRunner { * * @param controls An array of {@link InsetsSourceControl} that the caller newly receives. */ void updateSurfacePosition(SparseArray<InsetsSourceControl> controls); void updateSurfacePosition(@NonNull SparseArray<InsetsSourceControl> controls); /** * Returns {@code true} if this runner will keep playing the animation and updating the surface. Loading @@ -68,6 +71,7 @@ public interface InsetsAnimationControlRunner { /** * @return The animation this runner is running. */ @NonNull WindowInsetsAnimation getAnimation(); /** Loading @@ -80,11 +84,13 @@ public interface InsetsAnimationControlRunner { /** * @return The animation type this runner is running. */ @AnimationType int getAnimationType(); @AnimationType int getAnimationType(); /** * @return The {@link SurfaceParamsApplier} this runner is using. */ @NonNull SurfaceParamsApplier getSurfaceParamsApplier(); /** Loading @@ -102,14 +108,13 @@ public interface InsetsAnimationControlRunner { @LayoutInsetsDuringAnimation int layoutInsetsDuringAnimation); /** * * Export the state of classes that implement this interface into a protocol buffer * output stream. * * @param proto Stream to write the state to * @param fieldId FieldId of the implementation class */ void dumpDebug(ProtoOutputStream proto, long fieldId); void dumpDebug(@NonNull ProtoOutputStream proto, long fieldId); /** * Interface applying given surface operations. Loading @@ -117,7 +122,7 @@ public interface InsetsAnimationControlRunner { interface SurfaceParamsApplier { SurfaceParamsApplier DEFAULT = params -> { final SurfaceControl.Transaction t = new SurfaceControl.Transaction(); final var t = new SurfaceControl.Transaction(); for (int i = params.length - 1; i >= 0; i--) { SyncRtSurfaceTransactionApplier.applyParams(t, params[i], new float[9]); } Loading @@ -130,7 +135,7 @@ public interface InsetsAnimationControlRunner { * * @param params The {@link SyncRtSurfaceTransactionApplier.SurfaceParams} to apply. */ void applySurfaceParams(SyncRtSurfaceTransactionApplier.SurfaceParams... params); void applySurfaceParams(@NonNull SyncRtSurfaceTransactionApplier.SurfaceParams... params); } } core/java/android/view/InsetsAnimationSpec.java +2 −0 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ package android.view; import android.annotation.Nullable; import android.view.animation.Interpolator; import com.android.internal.annotations.VisibleForTesting; Loading @@ -35,5 +36,6 @@ public interface InsetsAnimationSpec { * @param hasZeroInsetsIme whether IME has no insets (floating, fullscreen or non-overlapping). * @return The interpolator used for the animation */ @Nullable Interpolator getInsetsInterpolator(boolean hasZeroInsetsIme); } core/java/android/view/InsetsAnimationThreadControlRunner.java +24 −15 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ package android.view; import static android.view.InsetsController.DEBUG; import android.annotation.NonNull; import android.annotation.Nullable; import android.annotation.UiThread; import android.content.res.CompatibilityInfo; Loading @@ -42,8 +43,11 @@ import android.view.inputmethod.ImeTracker; public class InsetsAnimationThreadControlRunner implements InsetsAnimationControlRunner { private static final String TAG = "InsetsAnimThreadRunner"; @NonNull private final InsetsAnimationControlImpl mControl; @NonNull private final InsetsAnimationControlCallbacks mOuterCallbacks; @NonNull private final Handler mMainThreadHandler; private final InsetsAnimationControlCallbacks mCallbacks = new InsetsAnimationControlCallbacks() { Loading @@ -51,13 +55,14 @@ public class InsetsAnimationThreadControlRunner implements InsetsAnimationContro @Override @UiThread public <T extends InsetsAnimationControlRunner & InternalInsetsAnimationController> void startAnimation(T runner, WindowInsetsAnimationControlListener listener, int types, WindowInsetsAnimation animation, Bounds bounds) { void startAnimation(@NonNull T runner, @NonNull WindowInsetsAnimationControlListener listener, @InsetsType int types, @NonNull WindowInsetsAnimation animation, @NonNull Bounds bounds) { // Animation will be started in constructor already. } @Override public void scheduleApplyChangeInsets(InsetsAnimationControlRunner runner) { public void scheduleApplyChangeInsets(@NonNull InsetsAnimationControlRunner runner) { synchronized (mControl) { // This reads the surface position on the animation thread, but the surface position // would be updated on the UI thread, so we need this critical section. Loading @@ -67,7 +72,7 @@ public class InsetsAnimationThreadControlRunner implements InsetsAnimationContro } @Override public void notifyFinished(InsetsAnimationControlRunner runner, boolean shown) { public void notifyFinished(@NonNull InsetsAnimationControlRunner runner, boolean shown) { Trace.asyncTraceEnd(Trace.TRACE_TAG_VIEW, "InsetsAsyncAnimation: " + WindowInsets.Type.toString(runner.getTypes()), runner.getTypes()); Loading @@ -77,14 +82,14 @@ public class InsetsAnimationThreadControlRunner implements InsetsAnimationContro } @Override public void releaseSurfaceControlFromRt(SurfaceControl sc) { public void releaseSurfaceControlFromRt(@NonNull SurfaceControl sc) { if (DEBUG) Log.d(TAG, "releaseSurfaceControlFromRt"); // Since we don't push the SurfaceParams to the RT we can release directly sc.release(); } @Override public void reportPerceptible(int types, boolean perceptible) { public void reportPerceptible(@InsetsType int types, boolean perceptible) { mMainThreadHandler.post(() -> mOuterCallbacks.reportPerceptible(types, perceptible)); } }; Loading @@ -94,7 +99,8 @@ public class InsetsAnimationThreadControlRunner implements InsetsAnimationContro private final float[] mTmpFloat9 = new float[9]; @Override public void applySurfaceParams(SyncRtSurfaceTransactionApplier.SurfaceParams... params) { public void applySurfaceParams( @NonNull SyncRtSurfaceTransactionApplier.SurfaceParams... params) { final SurfaceControl.Transaction t = new SurfaceControl.Transaction(); for (int i = params.length - 1; i >= 0; i--) { SyncRtSurfaceTransactionApplier.applyParams(t, params[i], mTmpFloat9); Loading @@ -106,13 +112,13 @@ public class InsetsAnimationThreadControlRunner implements InsetsAnimationContro }; @UiThread public InsetsAnimationThreadControlRunner(SparseArray<InsetsSourceControl> controls, @Nullable Rect frame, @Nullable Rect bounds, InsetsState state, WindowInsetsAnimationControlListener listener, @InsetsType int types, InsetsAnimationControlCallbacks controller, InsetsAnimationSpec insetsAnimationSpec, @AnimationType int animationType, public InsetsAnimationThreadControlRunner(@NonNull SparseArray<InsetsSourceControl> controls, @Nullable Rect frame, @Nullable Rect bounds, @NonNull InsetsState state, @NonNull WindowInsetsAnimationControlListener listener, @InsetsType int types, @NonNull InsetsAnimationControlCallbacks controller, @NonNull InsetsAnimationSpec insetsAnimationSpec, @AnimationType int animationType, @LayoutInsetsDuringAnimation int layoutInsetsDuringAnimation, CompatibilityInfo.Translator translator, Handler mainThreadHandler, @Nullable CompatibilityInfo.Translator translator, @NonNull Handler mainThreadHandler, @Nullable ImeTracker.Token statsToken) { mMainThreadHandler = mainThreadHandler; mOuterCallbacks = controller; Loading @@ -131,7 +137,7 @@ public class InsetsAnimationThreadControlRunner implements InsetsAnimationContro @Override @UiThread public void dumpDebug(ProtoOutputStream proto, long fieldId) { public void dumpDebug(@NonNull ProtoOutputStream proto, long fieldId) { mControl.dumpDebug(proto, fieldId); } Loading Loading @@ -161,7 +167,7 @@ public class InsetsAnimationThreadControlRunner implements InsetsAnimationContro @Override @UiThread public void updateSurfacePosition(SparseArray<InsetsSourceControl> controls) { public void updateSurfacePosition(@NonNull SparseArray<InsetsSourceControl> controls) { synchronized (mControl) { // This is called from the UI thread, however, the surface position will be used on the // animation thread, so we need this critical section. See: scheduleApplyChangeInsets. Loading @@ -186,17 +192,20 @@ public class InsetsAnimationThreadControlRunner implements InsetsAnimationContro InsetsAnimationThread.getHandler().post(mControl::cancel); } @NonNull @Override @UiThread public WindowInsetsAnimation getAnimation() { return mControl.getAnimation(); } @AnimationType @Override public int getAnimationType() { return mControl.getAnimationType(); } @NonNull @Override public SurfaceParamsApplier getSurfaceParamsApplier() { return mSurfaceParamsApplier; Loading Loading
core/java/android/view/InsetsAnimationControlCallbacks.java +12 −8 Original line number Diff line number Diff line Loading @@ -16,12 +16,14 @@ package android.view; import android.annotation.NonNull; import android.view.WindowInsets.Type.InsetsType; import android.view.WindowInsetsAnimation.Bounds; /** * Provide an interface to let InsetsAnimationControlImpl and InsetsResizeAnimationRunner call back * into its owner. * * @hide */ public interface InsetsAnimationControlCallbacks { Loading @@ -36,33 +38,35 @@ public interface InsetsAnimationControlCallbacks { * </ul> */ <T extends InsetsAnimationControlRunner & InternalInsetsAnimationController> void startAnimation(T runner, WindowInsetsAnimationControlListener listener, int types, WindowInsetsAnimation animation, Bounds bounds); void startAnimation(@NonNull T runner, @NonNull WindowInsetsAnimationControlListener listener, @InsetsType int types, @NonNull WindowInsetsAnimation animation, @NonNull Bounds bounds); /** * Schedule the apply by posting the animation callback. * * @param runner The runner that requested applying insets */ void scheduleApplyChangeInsets(InsetsAnimationControlRunner runner); void scheduleApplyChangeInsets(@NonNull InsetsAnimationControlRunner runner); /** * Finish the final steps after the animation. * * @param runner The runner used to run the animation. * @param shown {@code true} if the insets are shown. */ void notifyFinished(InsetsAnimationControlRunner runner, boolean shown); void notifyFinished(@NonNull InsetsAnimationControlRunner runner, boolean shown); /** * Post a message to release the Surface, guaranteed to happen after all * previous calls to applySurfaceParams. */ void releaseSurfaceControlFromRt(SurfaceControl sc); void releaseSurfaceControlFromRt(@NonNull SurfaceControl sc); /** * Reports that the perceptibility of the given types has changed to the given value. * * A type is perceptible if it is not (almost) entirely off-screen and not (almost) entirely * <p>A type is perceptible if it is not (almost) entirely off-screen and not (almost) entirely * transparent. * * @param types the (public) types whose perceptibility has changed Loading
core/java/android/view/InsetsAnimationControlImpl.java +92 −45 Original line number Diff line number Diff line Loading @@ -46,6 +46,8 @@ import static android.view.inputmethod.ImeTracker.DEBUG_IME_VISIBILITY; import static com.android.internal.annotations.VisibleForTesting.Visibility.PACKAGE; import android.annotation.FloatRange; import android.annotation.NonNull; import android.annotation.Nullable; import android.content.res.CompatibilityInfo; import android.graphics.Insets; Loading @@ -69,10 +71,12 @@ import android.view.inputmethod.ImeTracker; import com.android.internal.annotations.VisibleForTesting; import java.util.ArrayList; import java.util.List; import java.util.Objects; /** * Implements {@link WindowInsetsAnimationController} * * @hide */ @VisibleForTesting(visibility = VisibleForTesting.Visibility.PACKAGE) Loading @@ -81,55 +85,77 @@ public class InsetsAnimationControlImpl implements InternalInsetsAnimationContro private static final String TAG = "InsetsAnimationCtrlImpl"; @NonNull private final Rect mTmpFrame = new Rect(); @NonNull private final WindowInsetsAnimationControlListener mListener; @NonNull private final SparseArray<InsetsSourceControl> mControls; @NonNull private final SparseSetArray<InsetsSourceControl> mSideControlsMap = new SparseSetArray<>(); /** @see WindowInsetsAnimationController#getHiddenStateInsets */ @NonNull private final Insets mHiddenInsets; /** @see WindowInsetsAnimationController#getShownStateInsets */ @NonNull private final Insets mShownInsets; @NonNull private final Matrix mTmpMatrix = new Matrix(); @NonNull private final InsetsState mInitialInsetsState; private final @AnimationType int mAnimationType; private @LayoutInsetsDuringAnimation int mLayoutInsetsDuringAnimation; private final @InsetsType int mTypes; private @InsetsType int mControllingTypes; @AnimationType private final int mAnimationType; @LayoutInsetsDuringAnimation private int mLayoutInsetsDuringAnimation; @InsetsType private final int mTypes; @InsetsType private int mControllingTypes; @NonNull private final InsetsAnimationControlCallbacks mController; @NonNull private final SurfaceParamsApplier mSurfaceParamsApplier; @NonNull private final WindowInsetsAnimation mAnimation; private final long mDurationMs; private final Interpolator mInterpolator; /** @see WindowInsetsAnimationController#hasZeroInsetsIme */ private final boolean mHasZeroInsetsIme; @Nullable private final CompatibilityInfo.Translator mTranslator; @Nullable private final ImeTracker.Token mStatsToken; @NonNull private Insets mCurrentInsets; @NonNull private Insets mPendingInsets; @FloatRange(from = 0f, to = 1f) private float mPendingFraction; private boolean mFinished; private boolean mCancelling; private boolean mCancelled; private boolean mShownOnFinish; @FloatRange(from = 0f, to = 1f) private float mCurrentAlpha = 1.0f; @FloatRange(from = 0f, to = 1f) private float mPendingAlpha = 1.0f; @VisibleForTesting(visibility = PACKAGE) private boolean mReadyDispatched; @Nullable private Boolean mPerceptible; @VisibleForTesting(visibility = PACKAGE) public InsetsAnimationControlImpl(SparseArray<InsetsSourceControl> controls, @Nullable Rect frame, @Nullable Rect bounds, InsetsState state, WindowInsetsAnimationControlListener listener, @InsetsType int types, InsetsAnimationControlCallbacks controller, SurfaceParamsApplier surfaceParamsApplier, InsetsAnimationSpec insetsAnimationSpec, @AnimationType int animationType, public InsetsAnimationControlImpl(@NonNull SparseArray<InsetsSourceControl> controls, @Nullable Rect frame, @Nullable Rect bounds, @NonNull InsetsState state, @NonNull WindowInsetsAnimationControlListener listener, @InsetsType int types, @NonNull InsetsAnimationControlCallbacks controller, @NonNull SurfaceParamsApplier surfaceParamsApplier, @NonNull InsetsAnimationSpec insetsAnimationSpec, @AnimationType int animationType, @LayoutInsetsDuringAnimation int layoutInsetsDuringAnimation, CompatibilityInfo.Translator translator, @Nullable ImeTracker.Token statsToken) { @Nullable CompatibilityInfo.Translator translator, @Nullable ImeTracker.Token statsToken) { mControls = controls; mListener = listener; mTypes = types; Loading Loading @@ -182,7 +208,7 @@ public class InsetsAnimationControlImpl implements InternalInsetsAnimationContro new Bounds(mHiddenInsets, mShownInsets)); } private boolean calculatePerceptible(Insets currentInsets, float currentAlpha) { private boolean calculatePerceptible(@NonNull Insets currentInsets, float currentAlpha) { return 100 * currentInsets.left >= 5 * (mShownInsets.left - mHiddenInsets.left) && 100 * currentInsets.top >= 5 * (mShownInsets.top - mHiddenInsets.top) && 100 * currentInsets.right >= 5 * (mShownInsets.right - mHiddenInsets.right) Loading Loading @@ -211,27 +237,32 @@ public class InsetsAnimationControlImpl implements InternalInsetsAnimationContro } @Override @NonNull public Insets getHiddenStateInsets() { return mHiddenInsets; } @Override @NonNull public Insets getShownStateInsets() { return mShownInsets; } @Override @NonNull public Insets getCurrentInsets() { return mCurrentInsets; } @Override @FloatRange(from = 0f, to = 1f) public float getCurrentAlpha() { return mCurrentAlpha; } @Override @InsetsType public int getTypes() { @InsetsType public int getTypes() { return mTypes; } Loading @@ -246,7 +277,7 @@ public class InsetsAnimationControlImpl implements InternalInsetsAnimationContro } @Override public void updateSurfacePosition(SparseArray<InsetsSourceControl> controls) { public void updateSurfacePosition(@NonNull SparseArray<InsetsSourceControl> controls) { for (int i = controls.size() - 1; i >= 0; i--) { final InsetsSourceControl control = controls.valueAt(i); final InsetsSourceControl c = mControls.get(control.getId()); Loading @@ -264,11 +295,13 @@ public class InsetsAnimationControlImpl implements InternalInsetsAnimationContro } @Override public @AnimationType int getAnimationType() { @AnimationType public int getAnimationType() { return mAnimationType; } @Override @NonNull public SurfaceParamsApplier getSurfaceParamsApplier() { return mSurfaceParamsApplier; } Loading @@ -280,12 +313,15 @@ public class InsetsAnimationControlImpl implements InternalInsetsAnimationContro } @Override public void setInsetsAndAlpha(Insets insets, float alpha, float fraction) { public void setInsetsAndAlpha(@Nullable Insets insets, @FloatRange(from = 0f, to = 1f) float alpha, @FloatRange(from = 0f, to = 1f) float fraction) { setInsetsAndAlpha(insets, alpha, fraction, false /* allowWhenFinished */); } private void setInsetsAndAlpha(Insets insets, float alpha, float fraction, boolean allowWhenFinished) { private void setInsetsAndAlpha(@Nullable Insets insets, @FloatRange(from = 0f, to = 1f) float alpha, @FloatRange(from = 0f, to = 1f) float fraction, boolean allowWhenFinished) { if (!allowWhenFinished && mFinished) { throw new IllegalStateException( "Can't change insets on an animation that is finished."); Loading @@ -308,28 +344,30 @@ public class InsetsAnimationControlImpl implements InternalInsetsAnimationContro /** * @return Whether the finish callback of this animation should be invoked. */ @VisibleForTesting @VisibleForTesting(visibility = VisibleForTesting.Visibility.PACKAGE) public boolean applyChangeInsets(@Nullable InsetsState outState) { if (mCancelled) { if (DEBUG) Log.d(TAG, "applyChangeInsets canceled"); return false; } final Insets offset = Insets.subtract(mShownInsets, mPendingInsets); final ArrayList<SurfaceParams> params = new ArrayList<>(); final var params = new ArrayList<SurfaceParams>(); updateLeashesForSide(SIDE_LEFT, offset.left, params, outState, mPendingAlpha); updateLeashesForSide(SIDE_TOP, offset.top, params, outState, mPendingAlpha); updateLeashesForSide(SIDE_RIGHT, offset.right, params, outState, mPendingAlpha); updateLeashesForSide(SIDE_BOTTOM, offset.bottom, params, outState, mPendingAlpha); mSurfaceParamsApplier.applySurfaceParams(params.toArray(new SurfaceParams[params.size()])); mSurfaceParamsApplier.applySurfaceParams(params.toArray(new SurfaceParams[0])); mCurrentInsets = mPendingInsets; mAnimation.setFraction(mPendingFraction); mCurrentAlpha = mPendingAlpha; mAnimation.setAlpha(mPendingAlpha); if (mFinished) { if (DEBUG) Log.d(TAG, String.format( "notifyFinished shown: %s, currentAlpha: %f, currentInsets: %s", mShownOnFinish, mCurrentAlpha, mCurrentInsets)); if (DEBUG) { Log.d(TAG, "notifyFinished shown: " + mShownOnFinish + ", currentAlpha: " + mCurrentAlpha + ", currentInsets: " + mCurrentInsets); } mController.notifyFinished(this, mShownOnFinish); releaseLeashes(); if (DEBUG) Log.d(TAG, "Animation finished abruptly."); Loading Loading @@ -367,6 +405,7 @@ public class InsetsAnimationControlImpl implements InternalInsetsAnimationContro @Override @VisibleForTesting @FloatRange(from = 0f, to = 1f) public float getCurrentFraction() { return mAnimation.getFraction(); } Loading Loading @@ -403,6 +442,7 @@ public class InsetsAnimationControlImpl implements InternalInsetsAnimationContro } @Override @NonNull public WindowInsetsAnimation getAnimation() { return mAnimation; } Loading @@ -414,7 +454,7 @@ public class InsetsAnimationControlImpl implements InternalInsetsAnimationContro } @Override public void dumpDebug(ProtoOutputStream proto, long fieldId) { public void dumpDebug(@NonNull ProtoOutputStream proto, long fieldId) { final long token = proto.start(fieldId); proto.write(IS_CANCELLED, mCancelled); proto.write(IS_FINISHED, mFinished); Loading @@ -427,12 +467,14 @@ public class InsetsAnimationControlImpl implements InternalInsetsAnimationContro proto.end(token); } @NonNull SparseArray<InsetsSourceControl> getControls() { return mControls; } private Insets getInsetsFromState(InsetsState state, Rect frame, Rect bounds, @Nullable @InternalInsetsSide SparseIntArray idSideMap) { @NonNull private Insets getInsetsFromState(@NonNull InsetsState state, @NonNull Rect frame, @NonNull Rect bounds, @Nullable @InternalInsetsSide SparseIntArray idSideMap) { return state.calculateInsets(frame, bounds, null /* ignoringVisibilityState */, false /* isScreenRound */, SOFT_INPUT_ADJUST_RESIZE /* legacySoftInputMode */, 0 /* legacyWindowFlags */, 0 /* legacySystemUiFlags */, TYPE_APPLICATION, Loading @@ -440,8 +482,9 @@ public class InsetsAnimationControlImpl implements InternalInsetsAnimationContro } /** Computes the insets relative to the given frame. */ private Insets calculateInsets(InsetsState state, Rect frame, Rect bounds, SparseArray<InsetsSourceControl> controls, boolean shown, @NonNull private Insets calculateInsets(@NonNull InsetsState state, @NonNull Rect frame, @NonNull Rect bounds, @NonNull SparseArray<InsetsSourceControl> controls, boolean shown, @Nullable @InternalInsetsSide SparseIntArray idSideMap) { for (int i = controls.size() - 1; i >= 0; i--) { final InsetsSourceControl control = controls.valueAt(i); Loading @@ -455,8 +498,9 @@ public class InsetsAnimationControlImpl implements InternalInsetsAnimationContro } /** Computes the insets from the insets hints of controls. */ private Insets calculateInsets(InsetsState state, SparseArray<InsetsSourceControl> controls, boolean shownOrCurrent) { @NonNull private Insets calculateInsets(@Nullable InsetsState state, @NonNull SparseArray<InsetsSourceControl> controls, boolean shownOrCurrent) { Insets insets = Insets.NONE; if (!shownOrCurrent) { return insets; Loading @@ -475,7 +519,8 @@ public class InsetsAnimationControlImpl implements InternalInsetsAnimationContro return insets; } private Insets sanitize(Insets insets) { @NonNull private Insets sanitize(@Nullable Insets insets) { if (insets == null) { insets = getCurrentInsets(); } Loading @@ -485,12 +530,14 @@ public class InsetsAnimationControlImpl implements InternalInsetsAnimationContro return Insets.max(Insets.min(insets, mShownInsets), mHiddenInsets); } private static float sanitize(float alpha) { @FloatRange(from = 0f, to = 1f) private static float sanitize(@FloatRange(from = 0f, to = 1f) float alpha) { return alpha >= 1 ? 1 : (alpha <= 0 ? 0 : alpha); } private void updateLeashesForSide(@InternalInsetsSide int side, int offset, ArrayList<SurfaceParams> surfaceParams, @Nullable InsetsState outState, float alpha) { @NonNull List<SurfaceParams> surfaceParams, @Nullable InsetsState outState, @FloatRange(from = 0f, to = 1f) float alpha) { final ArraySet<InsetsSourceControl> controls = mSideControlsMap.get(side); if (controls == null) { return; Loading Loading @@ -536,8 +583,8 @@ public class InsetsAnimationControlImpl implements InternalInsetsAnimationContro } } private void addTranslationToMatrix(@InternalInsetsSide int side, int offset, Matrix m, Rect frame) { private void addTranslationToMatrix(@InternalInsetsSide int side, int offset, @NonNull Matrix m, @NonNull Rect frame) { final float surfaceOffset = mTranslator != null ? mTranslator.translateLengthInAppWindowToScreen(offset) : offset; switch (side) { Loading @@ -560,9 +607,9 @@ public class InsetsAnimationControlImpl implements InternalInsetsAnimationContro } } private static void buildSideControlsMap(SparseIntArray idSideMap, SparseSetArray<InsetsSourceControl> sideControlsMap, SparseArray<InsetsSourceControl> controls) { private static void buildSideControlsMap(@NonNull SparseIntArray idSideMap, @NonNull SparseSetArray<InsetsSourceControl> sideControlsMap, @NonNull SparseArray<InsetsSourceControl> controls) { for (int i = idSideMap.size() - 1; i >= 0; i--) { final int type = idSideMap.keyAt(i); final int side = idSideMap.valueAt(i); Loading @@ -577,8 +624,8 @@ public class InsetsAnimationControlImpl implements InternalInsetsAnimationContro } private static void buildSideControlsMap( SparseSetArray<InsetsSourceControl> sideControlsMap, SparseArray<InsetsSourceControl> controls) { @NonNull SparseSetArray<InsetsSourceControl> sideControlsMap, @NonNull SparseArray<InsetsSourceControl> controls) { for (int i = controls.size() - 1; i >= 0; i--) { final InsetsSourceControl control = controls.valueAt(i); if (control == null) { Loading
core/java/android/view/InsetsAnimationControlRunner.java +15 −10 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ package android.view; import android.annotation.NonNull; import android.annotation.Nullable; import android.util.SparseArray; import android.util.proto.ProtoOutputStream; Loading @@ -34,13 +35,15 @@ public interface InsetsAnimationControlRunner { /** * @return The {@link InsetsType} the animation of this runner controls. */ @InsetsType int getTypes(); @InsetsType int getTypes(); /** * @return The {@link InsetsType} the animation of this runner is controlling. This can be * changed if a control is revoked. */ @InsetsType int getControllingTypes(); @InsetsType int getControllingTypes(); /** * Notifies {@link InsetsType types} of control are getting revoked. Loading @@ -52,7 +55,7 @@ public interface InsetsAnimationControlRunner { * * @param controls An array of {@link InsetsSourceControl} that the caller newly receives. */ void updateSurfacePosition(SparseArray<InsetsSourceControl> controls); void updateSurfacePosition(@NonNull SparseArray<InsetsSourceControl> controls); /** * Returns {@code true} if this runner will keep playing the animation and updating the surface. Loading @@ -68,6 +71,7 @@ public interface InsetsAnimationControlRunner { /** * @return The animation this runner is running. */ @NonNull WindowInsetsAnimation getAnimation(); /** Loading @@ -80,11 +84,13 @@ public interface InsetsAnimationControlRunner { /** * @return The animation type this runner is running. */ @AnimationType int getAnimationType(); @AnimationType int getAnimationType(); /** * @return The {@link SurfaceParamsApplier} this runner is using. */ @NonNull SurfaceParamsApplier getSurfaceParamsApplier(); /** Loading @@ -102,14 +108,13 @@ public interface InsetsAnimationControlRunner { @LayoutInsetsDuringAnimation int layoutInsetsDuringAnimation); /** * * Export the state of classes that implement this interface into a protocol buffer * output stream. * * @param proto Stream to write the state to * @param fieldId FieldId of the implementation class */ void dumpDebug(ProtoOutputStream proto, long fieldId); void dumpDebug(@NonNull ProtoOutputStream proto, long fieldId); /** * Interface applying given surface operations. Loading @@ -117,7 +122,7 @@ public interface InsetsAnimationControlRunner { interface SurfaceParamsApplier { SurfaceParamsApplier DEFAULT = params -> { final SurfaceControl.Transaction t = new SurfaceControl.Transaction(); final var t = new SurfaceControl.Transaction(); for (int i = params.length - 1; i >= 0; i--) { SyncRtSurfaceTransactionApplier.applyParams(t, params[i], new float[9]); } Loading @@ -130,7 +135,7 @@ public interface InsetsAnimationControlRunner { * * @param params The {@link SyncRtSurfaceTransactionApplier.SurfaceParams} to apply. */ void applySurfaceParams(SyncRtSurfaceTransactionApplier.SurfaceParams... params); void applySurfaceParams(@NonNull SyncRtSurfaceTransactionApplier.SurfaceParams... params); } }
core/java/android/view/InsetsAnimationSpec.java +2 −0 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ package android.view; import android.annotation.Nullable; import android.view.animation.Interpolator; import com.android.internal.annotations.VisibleForTesting; Loading @@ -35,5 +36,6 @@ public interface InsetsAnimationSpec { * @param hasZeroInsetsIme whether IME has no insets (floating, fullscreen or non-overlapping). * @return The interpolator used for the animation */ @Nullable Interpolator getInsetsInterpolator(boolean hasZeroInsetsIme); }
core/java/android/view/InsetsAnimationThreadControlRunner.java +24 −15 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ package android.view; import static android.view.InsetsController.DEBUG; import android.annotation.NonNull; import android.annotation.Nullable; import android.annotation.UiThread; import android.content.res.CompatibilityInfo; Loading @@ -42,8 +43,11 @@ import android.view.inputmethod.ImeTracker; public class InsetsAnimationThreadControlRunner implements InsetsAnimationControlRunner { private static final String TAG = "InsetsAnimThreadRunner"; @NonNull private final InsetsAnimationControlImpl mControl; @NonNull private final InsetsAnimationControlCallbacks mOuterCallbacks; @NonNull private final Handler mMainThreadHandler; private final InsetsAnimationControlCallbacks mCallbacks = new InsetsAnimationControlCallbacks() { Loading @@ -51,13 +55,14 @@ public class InsetsAnimationThreadControlRunner implements InsetsAnimationContro @Override @UiThread public <T extends InsetsAnimationControlRunner & InternalInsetsAnimationController> void startAnimation(T runner, WindowInsetsAnimationControlListener listener, int types, WindowInsetsAnimation animation, Bounds bounds) { void startAnimation(@NonNull T runner, @NonNull WindowInsetsAnimationControlListener listener, @InsetsType int types, @NonNull WindowInsetsAnimation animation, @NonNull Bounds bounds) { // Animation will be started in constructor already. } @Override public void scheduleApplyChangeInsets(InsetsAnimationControlRunner runner) { public void scheduleApplyChangeInsets(@NonNull InsetsAnimationControlRunner runner) { synchronized (mControl) { // This reads the surface position on the animation thread, but the surface position // would be updated on the UI thread, so we need this critical section. Loading @@ -67,7 +72,7 @@ public class InsetsAnimationThreadControlRunner implements InsetsAnimationContro } @Override public void notifyFinished(InsetsAnimationControlRunner runner, boolean shown) { public void notifyFinished(@NonNull InsetsAnimationControlRunner runner, boolean shown) { Trace.asyncTraceEnd(Trace.TRACE_TAG_VIEW, "InsetsAsyncAnimation: " + WindowInsets.Type.toString(runner.getTypes()), runner.getTypes()); Loading @@ -77,14 +82,14 @@ public class InsetsAnimationThreadControlRunner implements InsetsAnimationContro } @Override public void releaseSurfaceControlFromRt(SurfaceControl sc) { public void releaseSurfaceControlFromRt(@NonNull SurfaceControl sc) { if (DEBUG) Log.d(TAG, "releaseSurfaceControlFromRt"); // Since we don't push the SurfaceParams to the RT we can release directly sc.release(); } @Override public void reportPerceptible(int types, boolean perceptible) { public void reportPerceptible(@InsetsType int types, boolean perceptible) { mMainThreadHandler.post(() -> mOuterCallbacks.reportPerceptible(types, perceptible)); } }; Loading @@ -94,7 +99,8 @@ public class InsetsAnimationThreadControlRunner implements InsetsAnimationContro private final float[] mTmpFloat9 = new float[9]; @Override public void applySurfaceParams(SyncRtSurfaceTransactionApplier.SurfaceParams... params) { public void applySurfaceParams( @NonNull SyncRtSurfaceTransactionApplier.SurfaceParams... params) { final SurfaceControl.Transaction t = new SurfaceControl.Transaction(); for (int i = params.length - 1; i >= 0; i--) { SyncRtSurfaceTransactionApplier.applyParams(t, params[i], mTmpFloat9); Loading @@ -106,13 +112,13 @@ public class InsetsAnimationThreadControlRunner implements InsetsAnimationContro }; @UiThread public InsetsAnimationThreadControlRunner(SparseArray<InsetsSourceControl> controls, @Nullable Rect frame, @Nullable Rect bounds, InsetsState state, WindowInsetsAnimationControlListener listener, @InsetsType int types, InsetsAnimationControlCallbacks controller, InsetsAnimationSpec insetsAnimationSpec, @AnimationType int animationType, public InsetsAnimationThreadControlRunner(@NonNull SparseArray<InsetsSourceControl> controls, @Nullable Rect frame, @Nullable Rect bounds, @NonNull InsetsState state, @NonNull WindowInsetsAnimationControlListener listener, @InsetsType int types, @NonNull InsetsAnimationControlCallbacks controller, @NonNull InsetsAnimationSpec insetsAnimationSpec, @AnimationType int animationType, @LayoutInsetsDuringAnimation int layoutInsetsDuringAnimation, CompatibilityInfo.Translator translator, Handler mainThreadHandler, @Nullable CompatibilityInfo.Translator translator, @NonNull Handler mainThreadHandler, @Nullable ImeTracker.Token statsToken) { mMainThreadHandler = mainThreadHandler; mOuterCallbacks = controller; Loading @@ -131,7 +137,7 @@ public class InsetsAnimationThreadControlRunner implements InsetsAnimationContro @Override @UiThread public void dumpDebug(ProtoOutputStream proto, long fieldId) { public void dumpDebug(@NonNull ProtoOutputStream proto, long fieldId) { mControl.dumpDebug(proto, fieldId); } Loading Loading @@ -161,7 +167,7 @@ public class InsetsAnimationThreadControlRunner implements InsetsAnimationContro @Override @UiThread public void updateSurfacePosition(SparseArray<InsetsSourceControl> controls) { public void updateSurfacePosition(@NonNull SparseArray<InsetsSourceControl> controls) { synchronized (mControl) { // This is called from the UI thread, however, the surface position will be used on the // animation thread, so we need this critical section. See: scheduleApplyChangeInsets. Loading @@ -186,17 +192,20 @@ public class InsetsAnimationThreadControlRunner implements InsetsAnimationContro InsetsAnimationThread.getHandler().post(mControl::cancel); } @NonNull @Override @UiThread public WindowInsetsAnimation getAnimation() { return mControl.getAnimation(); } @AnimationType @Override public int getAnimationType() { return mControl.getAnimationType(); } @NonNull @Override public SurfaceParamsApplier getSurfaceParamsApplier() { return mSurfaceParamsApplier; Loading