Revert "Disable user animations on insets whose visible frame is empty"

This reverts commit 0b9450bab9.

Reason for revert:
Broke ImeInsetsControllerTest#testChangeSizeWhileControlling

Bug: 157777145
Fix: 159154994
Test: atest CtsInputMethodTestCases
Test: atest InsetsSourceConsumerTest
Change-Id: I6c47ec5f8498a3566c543d4d1d6ef62e325ccd8e
This commit is contained in:
Yohei Yukawa
2020-06-16 21:31:35 +00:00
parent 0b9450bab9
commit f35971dfca
4 changed files with 20 additions and 66 deletions

View File

@@ -485,12 +485,6 @@ public class InsetsController implements WindowInsetsController, InsetsAnimation
/** Set of inset types for which an animation was started since last resetting this field */
private @InsetsType int mLastStartedAnimTypes;
/** Set of inset types which cannot be controlled by the user animation */
private @InsetsType int mLastDisabledUserAnimationInsetsTypes;
private Runnable mInvokeControllableInsetsChangedListeners =
this::invokeControllableInsetsChangedListeners;
public InsetsController(Host host) {
this(host, (controller, type) -> {
if (type == ITYPE_IME) {
@@ -603,23 +597,9 @@ public class InsetsController implements WindowInsetsController, InsetsAnimation
private void updateState(InsetsState newState) {
mState.setDisplayFrame(newState.getDisplayFrame());
@InsetsType int disabledUserAnimationTypes = 0;
@InsetsType int[] cancelledUserAnimationTypes = {0};
for (int i = newState.getSourcesCount() - 1; i >= 0; i--) {
InsetsSource source = newState.sourceAt(i);
@InternalInsetsType int internalInsetsType = source.getType();
@AnimationType int animationType = getAnimationType(internalInsetsType);
if (source.isVisibleFrameEmpty()) {
@InsetsType int insetsType = toPublicType(internalInsetsType);
// The user animation is not allowed when visible frame is empty.
disabledUserAnimationTypes |= insetsType;
if (animationType == ANIMATION_TYPE_USER) {
// Existing user animation needs to be cancelled.
animationType = ANIMATION_TYPE_NONE;
cancelledUserAnimationTypes[0] |= insetsType;
}
}
getSourceConsumer(internalInsetsType).updateSource(source, animationType);
getSourceConsumer(source.getType()).updateSource(source);
}
for (int i = mState.getSourcesCount() - 1; i >= 0; i--) {
InsetsSource source = mState.sourceAt(i);
@@ -631,27 +611,6 @@ public class InsetsController implements WindowInsetsController, InsetsAnimation
mState.getSource(ITYPE_CAPTION_BAR).setFrame(new Rect(mFrame.left, mFrame.top,
mFrame.right, mFrame.top + mCaptionInsetsHeight));
}
updateDisabledUserAnimationTypes(disabledUserAnimationTypes);
if (cancelledUserAnimationTypes[0] != 0) {
mHandler.post(() -> show(cancelledUserAnimationTypes[0]));
}
}
private void updateDisabledUserAnimationTypes(@InsetsType int disabledUserAnimationTypes) {
@InsetsType int diff = mLastDisabledUserAnimationInsetsTypes ^ disabledUserAnimationTypes;
if (diff != 0) {
for (int i = mSourceConsumers.size() - 1; i >= 0; i--) {
InsetsSourceConsumer consumer = mSourceConsumers.valueAt(i);
if (consumer.getControl() != null && (toPublicType(consumer.mType) & diff) != 0) {
mHandler.removeCallbacks(mInvokeControllableInsetsChangedListeners);
mHandler.post(mInvokeControllableInsetsChangedListeners);
break;
}
}
mLastDisabledUserAnimationInsetsTypes = disabledUserAnimationTypes;
}
}
private boolean captionInsetsUnchanged() {
@@ -942,15 +901,6 @@ public class InsetsController implements WindowInsetsController, InsetsAnimation
boolean imeReady = true;
for (int i = internalTypes.size() - 1; i >= 0; i--) {
final InsetsSourceConsumer consumer = getSourceConsumer(internalTypes.valueAt(i));
if (animationType == ANIMATION_TYPE_USER) {
final InsetsSource source = mState.peekSource(consumer.getType());
if (source != null && source.isVisibleFrameEmpty()) {
if (WARN) Log.w(TAG, String.format(
"collectSourceControls can't run user animation for type: %s",
InsetsState.typeToString(consumer.getType())));
continue;
}
}
boolean show = animationType == ANIMATION_TYPE_SHOW
|| animationType == ANIMATION_TYPE_USER;
boolean canRun = false;
@@ -1341,8 +1291,7 @@ public class InsetsController implements WindowInsetsController, InsetsAnimation
@InsetsType int result = 0;
for (int i = mSourceConsumers.size() - 1; i >= 0; i--) {
InsetsSourceConsumer consumer = mSourceConsumers.valueAt(i);
InsetsSource source = mState.peekSource(consumer.mType);
if (consumer.getControl() != null && source != null && !source.isVisibleFrameEmpty()) {
if (consumer.getControl() != null) {
result |= toPublicType(consumer.mType);
}
}
@@ -1353,7 +1302,6 @@ public class InsetsController implements WindowInsetsController, InsetsAnimation
* @return The types that are now animating due to a listener invoking control/show/hide
*/
private @InsetsType int invokeControllableInsetsChangedListeners() {
mHandler.removeCallbacks(mInvokeControllableInsetsChangedListeners);
mLastStartedAnimTypes = 0;
@InsetsType int types = calculateControllableTypes();
int size = mControllableInsetsChangedListeners.size();

View File

@@ -92,10 +92,6 @@ public class InsetsSource implements Parcelable {
return mVisible;
}
public boolean isVisibleFrameEmpty() {
return mVisibleFrame != null && mVisibleFrame.isEmpty();
}
/**
* Calculates the insets this source will cause to a client window.
*

View File

@@ -18,8 +18,8 @@ package android.view;
import static android.view.InsetsController.ANIMATION_TYPE_NONE;
import static android.view.InsetsController.AnimationType;
import static android.view.InsetsController.DEBUG;
import static android.view.InsetsState.getDefaultVisibility;
import static android.view.InsetsController.DEBUG;
import static android.view.InsetsState.toPublicType;
import static com.android.internal.annotations.VisibleForTesting.Visibility.PACKAGE;
@@ -274,9 +274,9 @@ public class InsetsSourceConsumer {
}
@VisibleForTesting(visibility = PACKAGE)
public void updateSource(InsetsSource newSource, @AnimationType int animationType) {
public void updateSource(InsetsSource newSource) {
InsetsSource source = mState.peekSource(mType);
if (source == null || animationType == ANIMATION_TYPE_NONE
if (source == null || mController.getAnimationType(mType) == ANIMATION_TYPE_NONE
|| source.getFrame().equals(newSource.getFrame())) {
mPendingFrame = null;
mPendingVisibleFrame = null;
@@ -285,7 +285,7 @@ public class InsetsSourceConsumer {
}
// Frame is changing while animating. Keep note of the new frame but keep existing frame
// until animation is finished.
// until animaition is finished.
newSource = new InsetsSource(newSource);
mPendingFrame = new Rect(newSource.getFrame());
mPendingVisibleFrame = newSource.getVisibleFrame() != null