Loading core/java/android/view/ImeInsetsSourceConsumer.java +3 −3 Original line number Diff line number Diff line Loading @@ -221,13 +221,13 @@ public final class ImeInsetsSourceConsumer extends InsetsSourceConsumer { @Override public boolean setControl(@Nullable InsetsSourceControl control, int[] showTypes, int[] hideTypes) { int[] hideTypes, int[] cancelTypes) { if (Flags.refactorInsetsController()) { return super.setControl(control, showTypes, hideTypes); return super.setControl(control, showTypes, hideTypes, cancelTypes); } else { ImeTracing.getInstance().triggerClientDump("ImeInsetsSourceConsumer#setControl", mController.getHost().getInputMethodManager(), null /* icProto */); if (!super.setControl(control, showTypes, hideTypes)) { if (!super.setControl(control, showTypes, hideTypes, cancelTypes)) { return false; } if (control == null && !mIsRequestedVisibleAwaitingLeash) { Loading core/java/android/view/InsetsAnimationControlImpl.java +12 −6 Original line number Diff line number Diff line Loading @@ -371,6 +371,7 @@ public class InsetsAnimationControlImpl implements InternalInsetsAnimationContro mPendingInsets = mLayoutInsetsDuringAnimation == LAYOUT_INSETS_DURING_ANIMATION_SHOWN ? mShownInsets : mHiddenInsets; mPendingAlpha = 1f; mPendingFraction = 1f; applyChangeInsets(null); mCancelled = true; mListener.onCancelled(mReadyDispatched ? this : null); Loading Loading @@ -486,6 +487,17 @@ public class InsetsAnimationControlImpl implements InternalInsetsAnimationContro if (controls == null) { return; } final boolean visible = mPendingFraction == 0 // The first frame of ANIMATION_TYPE_SHOW should be invisible since it is // animated from the hidden state. ? mAnimationType != ANIMATION_TYPE_SHOW : mPendingFraction < 1f || (mFinished ? mShownOnFinish // If the animation is cancelled, mFinished and mShownOnFinish are not set. // Here uses mLayoutInsetsDuringAnimation to decide if it should be visible. : mLayoutInsetsDuringAnimation == LAYOUT_INSETS_DURING_ANIMATION_SHOWN); // TODO: Implement behavior when inset spans over multiple types for (int i = controls.size() - 1; i >= 0; i--) { final InsetsSourceControl control = controls.valueAt(i); Loading @@ -498,12 +510,6 @@ public class InsetsAnimationControlImpl implements InternalInsetsAnimationContro } addTranslationToMatrix(side, offset, mTmpMatrix, mTmpFrame); // The first frame of ANIMATION_TYPE_SHOW should be invisible since it is animated from // the hidden state. final boolean visible = mPendingFraction == 0 ? mAnimationType != ANIMATION_TYPE_SHOW : !mFinished || mShownOnFinish; if (outState != null && source != null) { outState.addSource(new InsetsSource(source) .setVisible(visible) Loading core/java/android/view/InsetsController.java +9 −4 Original line number Diff line number Diff line Loading @@ -957,6 +957,7 @@ public class InsetsController implements WindowInsetsController, InsetsAnimation int consumedControlCount = 0; final @InsetsType int[] showTypes = new int[1]; final @InsetsType int[] hideTypes = new int[1]; final @InsetsType int[] cancelTypes = new int[1]; ImeTracker.Token statsToken = null; // Ensure to update all existing source consumers Loading @@ -982,7 +983,7 @@ public class InsetsController implements WindowInsetsController, InsetsAnimation // control may be null, but we still need to update the control to null if it got // revoked. consumer.setControl(control, showTypes, hideTypes); consumer.setControl(control, showTypes, hideTypes, cancelTypes); } // Ensure to create source consumers if not available yet. Loading @@ -990,7 +991,7 @@ public class InsetsController implements WindowInsetsController, InsetsAnimation for (int i = mTmpControlArray.size() - 1; i >= 0; i--) { final InsetsSourceControl control = mTmpControlArray.valueAt(i); getSourceConsumer(control.getId(), control.getType()) .setControl(control, showTypes, hideTypes); .setControl(control, showTypes, hideTypes, cancelTypes); } } Loading @@ -1002,6 +1003,10 @@ public class InsetsController implements WindowInsetsController, InsetsAnimation } mTmpControlArray.clear(); if (cancelTypes[0] != 0) { cancelExistingControllers(cancelTypes[0]); } // Do not override any animations that the app started in the OnControllableInsetsChanged // listeners. int animatingTypes = invokeControllableInsetsChangedListeners(); Loading Loading @@ -2154,12 +2159,12 @@ public class InsetsController implements WindowInsetsController, InsetsAnimation new InsetsSourceControl(ID_IME_CAPTION_BAR, captionBar(), null /* leash */, false /* initialVisible */, new Point(), Insets.NONE), new int[1], new int[1]); new int[1], new int[1], new int[1]); } else { mState.removeSource(ID_IME_CAPTION_BAR); InsetsSourceConsumer sourceConsumer = mSourceConsumers.get(ID_IME_CAPTION_BAR); if (sourceConsumer != null) { sourceConsumer.setControl(null, new int[1], new int[1]); sourceConsumer.setControl(null, new int[1], new int[1], new int[1]); } } mHost.notifyInsetsChanged(); Loading core/java/android/view/InsetsSourceConsumer.java +8 −2 Original line number Diff line number Diff line Loading @@ -122,7 +122,7 @@ public class InsetsSourceConsumer { /** * Updates the control delivered from the server. * * @param showTypes An integer array with a single entry that determines which types a show * animation should be run after setting the control. * @param hideTypes An integer array with a single entry that determines which types a hide Loading @@ -130,7 +130,7 @@ public class InsetsSourceConsumer { * @return Whether the control has changed from the server */ public boolean setControl(@Nullable InsetsSourceControl control, @InsetsType int[] showTypes, @InsetsType int[] hideTypes) { @InsetsType int[] showTypes, @InsetsType int[] hideTypes, int[] cancelTypes) { if (Objects.equals(mSourceControl, control)) { if (mSourceControl != null && mSourceControl != control) { mSourceControl.release(SurfaceControl::release); Loading Loading @@ -165,6 +165,12 @@ public class InsetsSourceConsumer { // Reset the applier to the default one which has the most lightweight implementation. setSurfaceParamsApplier(InsetsAnimationControlRunner.SurfaceParamsApplier.DEFAULT); } else { if (lastControl != null && InsetsSource.getInsetSide(lastControl.getInsetsHint()) != InsetsSource.getInsetSide(control.getInsetsHint())) { // The source has been moved to a different side. The coordinates are stale. // Canceling existing animation if there is any. cancelTypes[0] |= mType; } final boolean requestedVisible = isRequestedVisibleAwaitingControl(); final SurfaceControl oldLeash = lastControl != null ? lastControl.getLeash() : null; final SurfaceControl newLeash = control.getLeash(); Loading core/tests/coretests/src/android/view/InsetsAnimationControlImplTest.java +2 −2 Original line number Diff line number Diff line Loading @@ -100,14 +100,14 @@ public class InsetsAnimationControlImplTest { topConsumer.setControl( new InsetsSourceControl(ID_STATUS_BAR, WindowInsets.Type.statusBars(), mStatusLeash, true, new Point(0, 0), Insets.of(0, 100, 0, 0)), new int[1], new int[1]); new int[1], new int[1], new int[1]); InsetsSourceConsumer navConsumer = new InsetsSourceConsumer(ID_NAVIGATION_BAR, WindowInsets.Type.navigationBars(), mInsetsState, mMockController); navConsumer.setControl( new InsetsSourceControl(ID_NAVIGATION_BAR, WindowInsets.Type.navigationBars(), mNavLeash, true, new Point(400, 0), Insets.of(0, 0, 100, 0)), new int[1], new int[1]); new int[1], new int[1], new int[1]); mMockController.setRequestedVisibleTypes(0, WindowInsets.Type.navigationBars()); navConsumer.applyLocalVisibilityOverride(); Loading Loading
core/java/android/view/ImeInsetsSourceConsumer.java +3 −3 Original line number Diff line number Diff line Loading @@ -221,13 +221,13 @@ public final class ImeInsetsSourceConsumer extends InsetsSourceConsumer { @Override public boolean setControl(@Nullable InsetsSourceControl control, int[] showTypes, int[] hideTypes) { int[] hideTypes, int[] cancelTypes) { if (Flags.refactorInsetsController()) { return super.setControl(control, showTypes, hideTypes); return super.setControl(control, showTypes, hideTypes, cancelTypes); } else { ImeTracing.getInstance().triggerClientDump("ImeInsetsSourceConsumer#setControl", mController.getHost().getInputMethodManager(), null /* icProto */); if (!super.setControl(control, showTypes, hideTypes)) { if (!super.setControl(control, showTypes, hideTypes, cancelTypes)) { return false; } if (control == null && !mIsRequestedVisibleAwaitingLeash) { Loading
core/java/android/view/InsetsAnimationControlImpl.java +12 −6 Original line number Diff line number Diff line Loading @@ -371,6 +371,7 @@ public class InsetsAnimationControlImpl implements InternalInsetsAnimationContro mPendingInsets = mLayoutInsetsDuringAnimation == LAYOUT_INSETS_DURING_ANIMATION_SHOWN ? mShownInsets : mHiddenInsets; mPendingAlpha = 1f; mPendingFraction = 1f; applyChangeInsets(null); mCancelled = true; mListener.onCancelled(mReadyDispatched ? this : null); Loading Loading @@ -486,6 +487,17 @@ public class InsetsAnimationControlImpl implements InternalInsetsAnimationContro if (controls == null) { return; } final boolean visible = mPendingFraction == 0 // The first frame of ANIMATION_TYPE_SHOW should be invisible since it is // animated from the hidden state. ? mAnimationType != ANIMATION_TYPE_SHOW : mPendingFraction < 1f || (mFinished ? mShownOnFinish // If the animation is cancelled, mFinished and mShownOnFinish are not set. // Here uses mLayoutInsetsDuringAnimation to decide if it should be visible. : mLayoutInsetsDuringAnimation == LAYOUT_INSETS_DURING_ANIMATION_SHOWN); // TODO: Implement behavior when inset spans over multiple types for (int i = controls.size() - 1; i >= 0; i--) { final InsetsSourceControl control = controls.valueAt(i); Loading @@ -498,12 +510,6 @@ public class InsetsAnimationControlImpl implements InternalInsetsAnimationContro } addTranslationToMatrix(side, offset, mTmpMatrix, mTmpFrame); // The first frame of ANIMATION_TYPE_SHOW should be invisible since it is animated from // the hidden state. final boolean visible = mPendingFraction == 0 ? mAnimationType != ANIMATION_TYPE_SHOW : !mFinished || mShownOnFinish; if (outState != null && source != null) { outState.addSource(new InsetsSource(source) .setVisible(visible) Loading
core/java/android/view/InsetsController.java +9 −4 Original line number Diff line number Diff line Loading @@ -957,6 +957,7 @@ public class InsetsController implements WindowInsetsController, InsetsAnimation int consumedControlCount = 0; final @InsetsType int[] showTypes = new int[1]; final @InsetsType int[] hideTypes = new int[1]; final @InsetsType int[] cancelTypes = new int[1]; ImeTracker.Token statsToken = null; // Ensure to update all existing source consumers Loading @@ -982,7 +983,7 @@ public class InsetsController implements WindowInsetsController, InsetsAnimation // control may be null, but we still need to update the control to null if it got // revoked. consumer.setControl(control, showTypes, hideTypes); consumer.setControl(control, showTypes, hideTypes, cancelTypes); } // Ensure to create source consumers if not available yet. Loading @@ -990,7 +991,7 @@ public class InsetsController implements WindowInsetsController, InsetsAnimation for (int i = mTmpControlArray.size() - 1; i >= 0; i--) { final InsetsSourceControl control = mTmpControlArray.valueAt(i); getSourceConsumer(control.getId(), control.getType()) .setControl(control, showTypes, hideTypes); .setControl(control, showTypes, hideTypes, cancelTypes); } } Loading @@ -1002,6 +1003,10 @@ public class InsetsController implements WindowInsetsController, InsetsAnimation } mTmpControlArray.clear(); if (cancelTypes[0] != 0) { cancelExistingControllers(cancelTypes[0]); } // Do not override any animations that the app started in the OnControllableInsetsChanged // listeners. int animatingTypes = invokeControllableInsetsChangedListeners(); Loading Loading @@ -2154,12 +2159,12 @@ public class InsetsController implements WindowInsetsController, InsetsAnimation new InsetsSourceControl(ID_IME_CAPTION_BAR, captionBar(), null /* leash */, false /* initialVisible */, new Point(), Insets.NONE), new int[1], new int[1]); new int[1], new int[1], new int[1]); } else { mState.removeSource(ID_IME_CAPTION_BAR); InsetsSourceConsumer sourceConsumer = mSourceConsumers.get(ID_IME_CAPTION_BAR); if (sourceConsumer != null) { sourceConsumer.setControl(null, new int[1], new int[1]); sourceConsumer.setControl(null, new int[1], new int[1], new int[1]); } } mHost.notifyInsetsChanged(); Loading
core/java/android/view/InsetsSourceConsumer.java +8 −2 Original line number Diff line number Diff line Loading @@ -122,7 +122,7 @@ public class InsetsSourceConsumer { /** * Updates the control delivered from the server. * * @param showTypes An integer array with a single entry that determines which types a show * animation should be run after setting the control. * @param hideTypes An integer array with a single entry that determines which types a hide Loading @@ -130,7 +130,7 @@ public class InsetsSourceConsumer { * @return Whether the control has changed from the server */ public boolean setControl(@Nullable InsetsSourceControl control, @InsetsType int[] showTypes, @InsetsType int[] hideTypes) { @InsetsType int[] showTypes, @InsetsType int[] hideTypes, int[] cancelTypes) { if (Objects.equals(mSourceControl, control)) { if (mSourceControl != null && mSourceControl != control) { mSourceControl.release(SurfaceControl::release); Loading Loading @@ -165,6 +165,12 @@ public class InsetsSourceConsumer { // Reset the applier to the default one which has the most lightweight implementation. setSurfaceParamsApplier(InsetsAnimationControlRunner.SurfaceParamsApplier.DEFAULT); } else { if (lastControl != null && InsetsSource.getInsetSide(lastControl.getInsetsHint()) != InsetsSource.getInsetSide(control.getInsetsHint())) { // The source has been moved to a different side. The coordinates are stale. // Canceling existing animation if there is any. cancelTypes[0] |= mType; } final boolean requestedVisible = isRequestedVisibleAwaitingControl(); final SurfaceControl oldLeash = lastControl != null ? lastControl.getLeash() : null; final SurfaceControl newLeash = control.getLeash(); Loading
core/tests/coretests/src/android/view/InsetsAnimationControlImplTest.java +2 −2 Original line number Diff line number Diff line Loading @@ -100,14 +100,14 @@ public class InsetsAnimationControlImplTest { topConsumer.setControl( new InsetsSourceControl(ID_STATUS_BAR, WindowInsets.Type.statusBars(), mStatusLeash, true, new Point(0, 0), Insets.of(0, 100, 0, 0)), new int[1], new int[1]); new int[1], new int[1], new int[1]); InsetsSourceConsumer navConsumer = new InsetsSourceConsumer(ID_NAVIGATION_BAR, WindowInsets.Type.navigationBars(), mInsetsState, mMockController); navConsumer.setControl( new InsetsSourceControl(ID_NAVIGATION_BAR, WindowInsets.Type.navigationBars(), mNavLeash, true, new Point(400, 0), Insets.of(0, 0, 100, 0)), new int[1], new int[1]); new int[1], new int[1], new int[1]); mMockController.setRequestedVisibleTypes(0, WindowInsets.Type.navigationBars()); navConsumer.applyLocalVisibilityOverride(); Loading