summaryrefslogtreecommitdiff
path: root/core/java/android/view/InsetsSourceConsumer.java
diff options
context:
space:
mode:
authorTiger Huang <tigerhuang@google.com>2020-04-16 23:26:49 +0800
committerTiger Huang <tigerhuang@google.com>2020-04-22 20:23:18 +0800
commite480e5f49c03f6bf12562db96e966052c126b6d2 (patch)
tree0ff7959724910d46645dabf2ddd82b435f17d78d /core/java/android/view/InsetsSourceConsumer.java
parent896cdcca42732ebaeb31cdb3c0c45e0746a85e77 (diff)
Do not dispatch leashes if they are not ready
The previous solution used a different transaction from the one used in SeamlessRotator#finish. So the transaction might be applied in an unexpected order between here and there when the target frame number is reached. This CL reverted the previous solution. Instead, we don't dispatch the leash if it is not ready. For the client, it won't play the animation until obtaining the leash. Fix: 154195854 Test: Rotate device to change the orientation in Camera, and see if navigation bar stays visible. Test: Check if transient bar can be shown/hidden/aborted as expected. Test: Make sure b/153104643 stay fixed. Test: atest InsetsPolicyTest Change-Id: I29f80f1c77615b0a3cde38df265220f48d66f117
Diffstat (limited to 'core/java/android/view/InsetsSourceConsumer.java')
-rw-r--r--core/java/android/view/InsetsSourceConsumer.java24
1 files changed, 21 insertions, 3 deletions
diff --git a/core/java/android/view/InsetsSourceConsumer.java b/core/java/android/view/InsetsSourceConsumer.java
index a72383913420..2dcfd899adf4 100644
--- a/core/java/android/view/InsetsSourceConsumer.java
+++ b/core/java/android/view/InsetsSourceConsumer.java
@@ -69,6 +69,13 @@ public class InsetsSourceConsumer {
private Rect mPendingFrame;
private Rect mPendingVisibleFrame;
+ /**
+ * Indicates if we have the pending animation. When we have the control, we need to play the
+ * animation if the requested visibility is different from the current state. But if we haven't
+ * had a leash yet, we will set this flag, and play the animation once we get the leash.
+ */
+ private boolean mIsAnimationPending;
+
public InsetsSourceConsumer(@InternalInsetsType int type, InsetsState state,
Supplier<Transaction> transactionSupplier, InsetsController controller) {
mType = type;
@@ -107,13 +114,21 @@ public class InsetsSourceConsumer {
} else {
// We are gaining control, and need to run an animation since previous state
// didn't match
- if (isRequestedVisibleAwaitingControl() != mState.getSource(mType).isVisible()) {
- if (isRequestedVisibleAwaitingControl()) {
+ final boolean requestedVisible = isRequestedVisibleAwaitingControl();
+ final boolean needAnimation = requestedVisible != mState.getSource(mType).isVisible();
+ if (control.getLeash() != null && (needAnimation || mIsAnimationPending)) {
+ if (requestedVisible) {
showTypes[0] |= toPublicType(getType());
} else {
hideTypes[0] |= toPublicType(getType());
}
+ mIsAnimationPending = false;
} else {
+ if (needAnimation) {
+ // 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;
+ }
// We are gaining control, but don't need to run an animation.
// However make sure that the leash visibility is still up to date.
if (applyLocalVisibilityOverride()) {
@@ -274,7 +289,10 @@ public class InsetsSourceConsumer {
* the moment.
*/
protected void setRequestedVisible(boolean requestedVisible) {
- mRequestedVisible = requestedVisible;
+ if (mRequestedVisible != requestedVisible) {
+ mRequestedVisible = requestedVisible;
+ mIsAnimationPending = false;
+ }
if (applyLocalVisibilityOverride()) {
mController.notifyVisibilityChanged();
}