From d89efebc9792a327a408293cb20026dfe22cd98d Mon Sep 17 00:00:00 2001 From: Jorim Jaggi Date: Tue, 22 Jan 2019 17:48:34 +0100 Subject: [PATCH] Reset visibility before creating leash Otherwise we create the leash with visibility=shown before the client can update it, creating a flicker. Test: Open IME, go home, observe no flicker Bug: 111084606 Change-Id: I38eadaef79c27036edf5a86b773f6695d463db5c --- core/java/android/view/InsetsSourceConsumer.java | 2 +- core/java/android/view/InsetsState.java | 2 +- .../coretests/src/android/view/InsetsStateTest.java | 10 +++++----- .../com/android/server/wm/InsetsSourceProvider.java | 5 +++-- 4 files changed, 10 insertions(+), 9 deletions(-) diff --git a/core/java/android/view/InsetsSourceConsumer.java b/core/java/android/view/InsetsSourceConsumer.java index 7937cb69b80ee..8e9305fa6b6aa 100644 --- a/core/java/android/view/InsetsSourceConsumer.java +++ b/core/java/android/view/InsetsSourceConsumer.java @@ -43,7 +43,7 @@ public class InsetsSourceConsumer { mState = state; mTransactionSupplier = transactionSupplier; mController = controller; - mVisible = InsetsState.getDefaultVisibly(type); + mVisible = InsetsState.getDefaultVisibility(type); } public void setControl(@Nullable InsetsSourceControl control) { diff --git a/core/java/android/view/InsetsState.java b/core/java/android/view/InsetsState.java index a6af1a296faf9..4f809fe6d54a3 100644 --- a/core/java/android/view/InsetsState.java +++ b/core/java/android/view/InsetsState.java @@ -278,7 +278,7 @@ public class InsetsState implements Parcelable { } } - public static boolean getDefaultVisibly(@InsetType int type) { + public static boolean getDefaultVisibility(@InsetType int type) { switch (type) { case TYPE_TOP_BAR: case TYPE_SIDE_BAR_1: diff --git a/core/tests/coretests/src/android/view/InsetsStateTest.java b/core/tests/coretests/src/android/view/InsetsStateTest.java index 2db2f5f2a4fdd..03af67df13d05 100644 --- a/core/tests/coretests/src/android/view/InsetsStateTest.java +++ b/core/tests/coretests/src/android/view/InsetsStateTest.java @@ -155,10 +155,10 @@ public class InsetsStateTest { @Test public void testGetDefaultVisibility() { - assertTrue(InsetsState.getDefaultVisibly(TYPE_TOP_BAR)); - assertTrue(InsetsState.getDefaultVisibly(TYPE_SIDE_BAR_1)); - assertTrue(InsetsState.getDefaultVisibly(TYPE_SIDE_BAR_2)); - assertTrue(InsetsState.getDefaultVisibly(TYPE_SIDE_BAR_3)); - assertFalse(InsetsState.getDefaultVisibly(TYPE_IME)); + assertTrue(InsetsState.getDefaultVisibility(TYPE_TOP_BAR)); + assertTrue(InsetsState.getDefaultVisibility(TYPE_SIDE_BAR_1)); + assertTrue(InsetsState.getDefaultVisibility(TYPE_SIDE_BAR_2)); + assertTrue(InsetsState.getDefaultVisibility(TYPE_SIDE_BAR_3)); + assertFalse(InsetsState.getDefaultVisibility(TYPE_IME)); } } diff --git a/services/core/java/com/android/server/wm/InsetsSourceProvider.java b/services/core/java/com/android/server/wm/InsetsSourceProvider.java index e79820338c55e..66666e681e7a6 100644 --- a/services/core/java/com/android/server/wm/InsetsSourceProvider.java +++ b/services/core/java/com/android/server/wm/InsetsSourceProvider.java @@ -69,7 +69,7 @@ class InsetsSourceProvider { InsetsSourceProvider(InsetsSource source, InsetsStateController stateController, DisplayContent displayContent) { - mClientVisible = InsetsState.getDefaultVisibly(source.getType()); + mClientVisible = InsetsState.getDefaultVisibility(source.getType()); mSource = source; mDisplayContent = displayContent; mStateController = stateController; @@ -153,6 +153,7 @@ class InsetsSourceProvider { return; } mAdapter = new ControlAdapter(); + setClientVisible(InsetsState.getDefaultVisibility(mSource.getType())); mWin.startAnimation(mDisplayContent.getPendingTransaction(), mAdapter, !mClientVisible /* hidden */); mControllingWin = target; @@ -219,7 +220,7 @@ class InsetsSourceProvider { public void onAnimationCancelled(SurfaceControl animationLeash) { if (mAdapter == this) { mStateController.notifyControlRevoked(mControllingWin, InsetsSourceProvider.this); - setClientVisible(InsetsState.getDefaultVisibly(mSource.getType())); + setClientVisible(InsetsState.getDefaultVisibility(mSource.getType())); mControl = null; mControllingWin = null; mAdapter = null;