summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Tiger Huang <tigerhuang@google.com> 2022-04-19 22:46:20 +0800
committer Tiger Huang <tigerhuang@google.com> 2022-04-20 15:35:32 +0800
commitf71bbcf9a4c58c3e41fea0e03fa1593cacc7359d (patch)
treecb17fb451a6de0e638857944f544e4dda56f008e
parent174c5ebb782fc8e9472c4d461bd2af1dc481db67 (diff)
Don't set animation pending when gaining fake control
There are 2 cases that an insets source control doesn't have a leash: 1. The server hasn't applied the transaction of the initialization of a leash yet. 2. The control is a fake control. It is dispatched when the insets source is shown transiently by the server and we don't want the client to change its layout. We should only defer the insets animation for case 1. This CL uses the insetsHint to tell if a control is fake or not. Fix: 227083463 Test: atest --iterations 10 OpenAppNonResizeableTest Change-Id: I45f75d8013f5723b782857101d070729cf082166
-rw-r--r--core/java/android/view/InsetsSourceConsumer.java9
-rw-r--r--core/java/android/view/InsetsSourceControl.java2
-rw-r--r--services/core/java/com/android/server/wm/InsetsSourceProvider.java2
3 files changed, 9 insertions, 4 deletions
diff --git a/core/java/android/view/InsetsSourceConsumer.java b/core/java/android/view/InsetsSourceConsumer.java
index 6aab6359d23e..4d9033df89e1 100644
--- a/core/java/android/view/InsetsSourceConsumer.java
+++ b/core/java/android/view/InsetsSourceConsumer.java
@@ -25,6 +25,7 @@ import static android.view.InsetsSourceConsumerProto.IS_REQUESTED_VISIBLE;
import static android.view.InsetsSourceConsumerProto.PENDING_FRAME;
import static android.view.InsetsSourceConsumerProto.PENDING_VISIBLE_FRAME;
import static android.view.InsetsSourceConsumerProto.SOURCE_CONTROL;
+import static android.view.InsetsSourceControl.INVALID_HINTS;
import static android.view.InsetsState.ITYPE_IME;
import static android.view.InsetsState.getDefaultVisibility;
import static android.view.InsetsState.toPublicType;
@@ -163,8 +164,10 @@ public class InsetsSourceConsumer {
// We are gaining control, and need to run an animation since previous state
// didn't match
final boolean requestedVisible = isRequestedVisibleAwaitingControl();
- final boolean needAnimation = requestedVisible != mState.getSource(mType).isVisible();
- if (control.getLeash() != null && (needAnimation || mIsAnimationPending)) {
+ final boolean fakeControl = INVALID_HINTS.equals(control.getInsetsHint());
+ final boolean needsAnimation = requestedVisible != mState.getSource(mType).isVisible()
+ && !fakeControl;
+ if (control.getLeash() != null && (needsAnimation || mIsAnimationPending)) {
if (DEBUG) Log.d(TAG, String.format("Gaining control in %s, requestedVisible: %b",
mController.getHost().getRootViewTitle(), requestedVisible));
if (requestedVisible) {
@@ -174,7 +177,7 @@ public class InsetsSourceConsumer {
}
mIsAnimationPending = false;
} else {
- if (needAnimation) {
+ if (needsAnimation) {
// We need animation but we haven't had a leash yet. Set this flag that when we
// get the leash we can play the deferred animation.
mIsAnimationPending = true;
diff --git a/core/java/android/view/InsetsSourceControl.java b/core/java/android/view/InsetsSourceControl.java
index 9d98a3e4b0e1..2cf827db38db 100644
--- a/core/java/android/view/InsetsSourceControl.java
+++ b/core/java/android/view/InsetsSourceControl.java
@@ -39,6 +39,8 @@ import java.util.function.Consumer;
*/
public class InsetsSourceControl implements Parcelable {
+ public static final Insets INVALID_HINTS = Insets.of(-1, -1, -1, -1);
+
private final @InternalInsetsType int mType;
private final @Nullable SurfaceControl mLeash;
private final Point mSurfacePosition;
diff --git a/services/core/java/com/android/server/wm/InsetsSourceProvider.java b/services/core/java/com/android/server/wm/InsetsSourceProvider.java
index e04644c564f8..8413c5442536 100644
--- a/services/core/java/com/android/server/wm/InsetsSourceProvider.java
+++ b/services/core/java/com/android/server/wm/InsetsSourceProvider.java
@@ -123,7 +123,7 @@ abstract class InsetsSourceProvider {
mDisplayContent = displayContent;
mStateController = stateController;
mFakeControl = new InsetsSourceControl(
- source.getType(), null /* leash */, new Point(), Insets.NONE);
+ source.getType(), null /* leash */, new Point(), InsetsSourceControl.INVALID_HINTS);
mControllable = InsetsPolicy.isInsetsTypeControllable(source.getType());
}