Loading core/java/android/view/InsetsAnimationControlImpl.java +5 −0 Original line number Diff line number Diff line Loading @@ -256,6 +256,11 @@ public class InsetsAnimationControlImpl implements InternalInsetsAnimationContro } } @Override public boolean willUpdateSurface() { return !mFinished && !mCancelled; } @Override public @AnimationType int getAnimationType() { return mAnimationType; Loading core/java/android/view/InsetsAnimationControlRunner.java +6 −0 Original line number Diff line number Diff line Loading @@ -54,6 +54,12 @@ public interface InsetsAnimationControlRunner { */ void updateSurfacePosition(SparseArray<InsetsSourceControl> controls); /** * Returns {@code true} if this runner will keep playing the animation and updating the surface. * {@code false} otherwise. */ boolean willUpdateSurface(); /** * Cancels the animation. */ Loading core/java/android/view/InsetsAnimationThreadControlRunner.java +12 −1 Original line number Diff line number Diff line Loading @@ -89,7 +89,7 @@ public class InsetsAnimationThreadControlRunner implements InsetsAnimationContro } }; private SurfaceParamsApplier mSurfaceParamsApplier = new SurfaceParamsApplier() { private final SurfaceParamsApplier mSurfaceParamsApplier = new SurfaceParamsApplier() { private final float[] mTmpFloat9 = new float[9]; Loading Loading @@ -168,6 +168,17 @@ public class InsetsAnimationThreadControlRunner implements InsetsAnimationContro } } @Override @UiThread public boolean willUpdateSurface() { synchronized (mControl) { // This is called from the UI thread, however, applyChangeInsets would be called on the // animation thread, so we need this critical section to ensure this is not called // during applyChangeInsets. See: scheduleApplyChangeInsets. return mControl.willUpdateSurface(); } } @Override @UiThread public void cancel() { Loading core/java/android/view/InsetsController.java +36 −20 Original line number Diff line number Diff line Loading @@ -1747,9 +1747,9 @@ public class InsetsController implements WindowInsetsController, InsetsAnimation mTypesBeingCancelled |= types; try { for (int i = mRunningAnimations.size() - 1; i >= 0; i--) { InsetsAnimationControlRunner control = mRunningAnimations.get(i).runner; if ((control.getTypes() & types) != 0) { cancelAnimation(control, true /* invokeCallback */); final InsetsAnimationControlRunner runner = mRunningAnimations.get(i).runner; if ((runner.getTypes() & types) != 0) { cancelAnimation(runner, true /* invokeCallback */); } } if ((types & ime()) != 0) { Loading Loading @@ -1807,10 +1807,10 @@ public class InsetsController implements WindowInsetsController, InsetsAnimation void notifyControlRevoked(InsetsSourceConsumer consumer) { final @InsetsType int type = consumer.getType(); for (int i = mRunningAnimations.size() - 1; i >= 0; i--) { InsetsAnimationControlRunner control = mRunningAnimations.get(i).runner; control.notifyControlRevoked(type); if (control.getControllingTypes() == 0) { cancelAnimation(control, true /* invokeCallback */); final InsetsAnimationControlRunner runner = mRunningAnimations.get(i).runner; runner.notifyControlRevoked(type); if (runner.getControllingTypes() == 0) { cancelAnimation(runner, true /* invokeCallback */); } } if (type == ime()) { Loading @@ -1823,38 +1823,38 @@ public class InsetsController implements WindowInsetsController, InsetsAnimation } } private void cancelAnimation(InsetsAnimationControlRunner control, boolean invokeCallback) { private void cancelAnimation(InsetsAnimationControlRunner runner, boolean invokeCallback) { if (invokeCallback) { ImeTracker.forLogging().onCancelled(control.getStatsToken(), ImeTracker.forLogging().onCancelled(runner.getStatsToken(), ImeTracker.PHASE_CLIENT_ANIMATION_CANCEL); control.cancel(); runner.cancel(); } else { // Succeeds if invokeCallback is false (i.e. when called from notifyFinished). ImeTracker.forLogging().onProgress(control.getStatsToken(), ImeTracker.forLogging().onProgress(runner.getStatsToken(), ImeTracker.PHASE_CLIENT_ANIMATION_CANCEL); } if (DEBUG) { Log.d(TAG, TextUtils.formatSimple( "cancelAnimation of types: %d, animType: %d, host: %s", control.getTypes(), control.getAnimationType(), mHost.getRootViewTitle())); runner.getTypes(), runner.getAnimationType(), mHost.getRootViewTitle())); } @InsetsType int removedTypes = 0; for (int i = mRunningAnimations.size() - 1; i >= 0; i--) { RunningAnimation runningAnimation = mRunningAnimations.get(i); if (runningAnimation.runner == control) { if (runningAnimation.runner == runner) { mRunningAnimations.remove(i); removedTypes = control.getTypes(); removedTypes = runner.getTypes(); if (invokeCallback) { dispatchAnimationEnd(runningAnimation.runner.getAnimation()); } else { if (Flags.refactorInsetsController()) { if ((removedTypes & ime()) != 0 && control.getAnimationType() == ANIMATION_TYPE_HIDE) { && runner.getAnimationType() == ANIMATION_TYPE_HIDE) { if (mHost != null) { // if the (hide) animation is cancelled, the // requestedVisibleTypes should be reported at this point. reportRequestedVisibleTypes(!Flags.reportAnimatingInsetsTypes() ? control.getStatsToken() : null); ? runner.getStatsToken() : null); mHost.getInputMethodManager().removeImeSurface( mHost.getWindowToken()); } Loading @@ -1869,9 +1869,9 @@ public class InsetsController implements WindowInsetsController, InsetsAnimation if (mHost != null) { final boolean dispatchStatsToken = Flags.reportAnimatingInsetsTypes() && (removedTypes & ime()) != 0 && control.getAnimationType() == ANIMATION_TYPE_HIDE; && runner.getAnimationType() == ANIMATION_TYPE_HIDE; mHost.updateAnimatingTypes(mAnimatingTypes, dispatchStatsToken ? control.getStatsToken() : null); dispatchStatsToken ? runner.getStatsToken() : null); } } Loading Loading @@ -1959,14 +1959,30 @@ public class InsetsController implements WindowInsetsController, InsetsAnimation @VisibleForTesting(visibility = PACKAGE) public @AnimationType int getAnimationType(@InsetsType int type) { for (int i = mRunningAnimations.size() - 1; i >= 0; i--) { InsetsAnimationControlRunner control = mRunningAnimations.get(i).runner; if (control.controlsType(type)) { final InsetsAnimationControlRunner runner = mRunningAnimations.get(i).runner; if (runner.controlsType(type)) { return mRunningAnimations.get(i).type; } } return ANIMATION_TYPE_NONE; } /** * Returns {@code true} if there is an animation which controls the given {@link InsetsType} and * the runner is still playing the surface animation. * * @see InsetsAnimationControlRunner#willUpdateSurface() */ boolean hasSurfaceAnimation(@InsetsType int type) { for (int i = mRunningAnimations.size() - 1; i >= 0; i--) { final InsetsAnimationControlRunner runner = mRunningAnimations.get(i).runner; if (runner.controlsType(type) && runner.willUpdateSurface()) { return true; } } return false; } @VisibleForTesting(visibility = PACKAGE) public void setRequestedVisibleTypes(@InsetsType int visibleTypes, @InsetsType int mask) { final @InsetsType int requestedVisibleTypes = Loading core/java/android/view/InsetsResizeAnimationRunner.java +5 −0 Original line number Diff line number Diff line Loading @@ -232,6 +232,11 @@ public class InsetsResizeAnimationRunner implements InsetsAnimationControlRunner public void updateSurfacePosition(SparseArray<InsetsSourceControl> controls) { } @Override public boolean willUpdateSurface() { return false; } @Override public boolean hasZeroInsetsIme() { return false; Loading Loading
core/java/android/view/InsetsAnimationControlImpl.java +5 −0 Original line number Diff line number Diff line Loading @@ -256,6 +256,11 @@ public class InsetsAnimationControlImpl implements InternalInsetsAnimationContro } } @Override public boolean willUpdateSurface() { return !mFinished && !mCancelled; } @Override public @AnimationType int getAnimationType() { return mAnimationType; Loading
core/java/android/view/InsetsAnimationControlRunner.java +6 −0 Original line number Diff line number Diff line Loading @@ -54,6 +54,12 @@ public interface InsetsAnimationControlRunner { */ void updateSurfacePosition(SparseArray<InsetsSourceControl> controls); /** * Returns {@code true} if this runner will keep playing the animation and updating the surface. * {@code false} otherwise. */ boolean willUpdateSurface(); /** * Cancels the animation. */ Loading
core/java/android/view/InsetsAnimationThreadControlRunner.java +12 −1 Original line number Diff line number Diff line Loading @@ -89,7 +89,7 @@ public class InsetsAnimationThreadControlRunner implements InsetsAnimationContro } }; private SurfaceParamsApplier mSurfaceParamsApplier = new SurfaceParamsApplier() { private final SurfaceParamsApplier mSurfaceParamsApplier = new SurfaceParamsApplier() { private final float[] mTmpFloat9 = new float[9]; Loading Loading @@ -168,6 +168,17 @@ public class InsetsAnimationThreadControlRunner implements InsetsAnimationContro } } @Override @UiThread public boolean willUpdateSurface() { synchronized (mControl) { // This is called from the UI thread, however, applyChangeInsets would be called on the // animation thread, so we need this critical section to ensure this is not called // during applyChangeInsets. See: scheduleApplyChangeInsets. return mControl.willUpdateSurface(); } } @Override @UiThread public void cancel() { Loading
core/java/android/view/InsetsController.java +36 −20 Original line number Diff line number Diff line Loading @@ -1747,9 +1747,9 @@ public class InsetsController implements WindowInsetsController, InsetsAnimation mTypesBeingCancelled |= types; try { for (int i = mRunningAnimations.size() - 1; i >= 0; i--) { InsetsAnimationControlRunner control = mRunningAnimations.get(i).runner; if ((control.getTypes() & types) != 0) { cancelAnimation(control, true /* invokeCallback */); final InsetsAnimationControlRunner runner = mRunningAnimations.get(i).runner; if ((runner.getTypes() & types) != 0) { cancelAnimation(runner, true /* invokeCallback */); } } if ((types & ime()) != 0) { Loading Loading @@ -1807,10 +1807,10 @@ public class InsetsController implements WindowInsetsController, InsetsAnimation void notifyControlRevoked(InsetsSourceConsumer consumer) { final @InsetsType int type = consumer.getType(); for (int i = mRunningAnimations.size() - 1; i >= 0; i--) { InsetsAnimationControlRunner control = mRunningAnimations.get(i).runner; control.notifyControlRevoked(type); if (control.getControllingTypes() == 0) { cancelAnimation(control, true /* invokeCallback */); final InsetsAnimationControlRunner runner = mRunningAnimations.get(i).runner; runner.notifyControlRevoked(type); if (runner.getControllingTypes() == 0) { cancelAnimation(runner, true /* invokeCallback */); } } if (type == ime()) { Loading @@ -1823,38 +1823,38 @@ public class InsetsController implements WindowInsetsController, InsetsAnimation } } private void cancelAnimation(InsetsAnimationControlRunner control, boolean invokeCallback) { private void cancelAnimation(InsetsAnimationControlRunner runner, boolean invokeCallback) { if (invokeCallback) { ImeTracker.forLogging().onCancelled(control.getStatsToken(), ImeTracker.forLogging().onCancelled(runner.getStatsToken(), ImeTracker.PHASE_CLIENT_ANIMATION_CANCEL); control.cancel(); runner.cancel(); } else { // Succeeds if invokeCallback is false (i.e. when called from notifyFinished). ImeTracker.forLogging().onProgress(control.getStatsToken(), ImeTracker.forLogging().onProgress(runner.getStatsToken(), ImeTracker.PHASE_CLIENT_ANIMATION_CANCEL); } if (DEBUG) { Log.d(TAG, TextUtils.formatSimple( "cancelAnimation of types: %d, animType: %d, host: %s", control.getTypes(), control.getAnimationType(), mHost.getRootViewTitle())); runner.getTypes(), runner.getAnimationType(), mHost.getRootViewTitle())); } @InsetsType int removedTypes = 0; for (int i = mRunningAnimations.size() - 1; i >= 0; i--) { RunningAnimation runningAnimation = mRunningAnimations.get(i); if (runningAnimation.runner == control) { if (runningAnimation.runner == runner) { mRunningAnimations.remove(i); removedTypes = control.getTypes(); removedTypes = runner.getTypes(); if (invokeCallback) { dispatchAnimationEnd(runningAnimation.runner.getAnimation()); } else { if (Flags.refactorInsetsController()) { if ((removedTypes & ime()) != 0 && control.getAnimationType() == ANIMATION_TYPE_HIDE) { && runner.getAnimationType() == ANIMATION_TYPE_HIDE) { if (mHost != null) { // if the (hide) animation is cancelled, the // requestedVisibleTypes should be reported at this point. reportRequestedVisibleTypes(!Flags.reportAnimatingInsetsTypes() ? control.getStatsToken() : null); ? runner.getStatsToken() : null); mHost.getInputMethodManager().removeImeSurface( mHost.getWindowToken()); } Loading @@ -1869,9 +1869,9 @@ public class InsetsController implements WindowInsetsController, InsetsAnimation if (mHost != null) { final boolean dispatchStatsToken = Flags.reportAnimatingInsetsTypes() && (removedTypes & ime()) != 0 && control.getAnimationType() == ANIMATION_TYPE_HIDE; && runner.getAnimationType() == ANIMATION_TYPE_HIDE; mHost.updateAnimatingTypes(mAnimatingTypes, dispatchStatsToken ? control.getStatsToken() : null); dispatchStatsToken ? runner.getStatsToken() : null); } } Loading Loading @@ -1959,14 +1959,30 @@ public class InsetsController implements WindowInsetsController, InsetsAnimation @VisibleForTesting(visibility = PACKAGE) public @AnimationType int getAnimationType(@InsetsType int type) { for (int i = mRunningAnimations.size() - 1; i >= 0; i--) { InsetsAnimationControlRunner control = mRunningAnimations.get(i).runner; if (control.controlsType(type)) { final InsetsAnimationControlRunner runner = mRunningAnimations.get(i).runner; if (runner.controlsType(type)) { return mRunningAnimations.get(i).type; } } return ANIMATION_TYPE_NONE; } /** * Returns {@code true} if there is an animation which controls the given {@link InsetsType} and * the runner is still playing the surface animation. * * @see InsetsAnimationControlRunner#willUpdateSurface() */ boolean hasSurfaceAnimation(@InsetsType int type) { for (int i = mRunningAnimations.size() - 1; i >= 0; i--) { final InsetsAnimationControlRunner runner = mRunningAnimations.get(i).runner; if (runner.controlsType(type) && runner.willUpdateSurface()) { return true; } } return false; } @VisibleForTesting(visibility = PACKAGE) public void setRequestedVisibleTypes(@InsetsType int visibleTypes, @InsetsType int mask) { final @InsetsType int requestedVisibleTypes = Loading
core/java/android/view/InsetsResizeAnimationRunner.java +5 −0 Original line number Diff line number Diff line Loading @@ -232,6 +232,11 @@ public class InsetsResizeAnimationRunner implements InsetsAnimationControlRunner public void updateSurfacePosition(SparseArray<InsetsSourceControl> controls) { } @Override public boolean willUpdateSurface() { return false; } @Override public boolean hasZeroInsetsIme() { return false; Loading