From e8bd5284d33386d1c2a7d3109d9ad6cbd08e3423 Mon Sep 17 00:00:00 2001 From: Tiger Huang Date: Thu, 3 Sep 2020 23:01:21 +0800 Subject: [PATCH] Notify visibility change if source visibility is changed This makes view root dispatch the up-to-date WindowInsets to the app. Fix: 166619182 Test: Steps in the bug (comment#12) Change-Id: I8c47e3be84357f65084a7d9994f7d7b68f15611e (cherry picked from commit fd9435130557b054d203835eab6f287fee58ec1b) --- core/java/android/view/InsetsSourceConsumer.java | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/core/java/android/view/InsetsSourceConsumer.java b/core/java/android/view/InsetsSourceConsumer.java index 700dc66fab556..ba40459692f79 100644 --- a/core/java/android/view/InsetsSourceConsumer.java +++ b/core/java/android/view/InsetsSourceConsumer.java @@ -113,13 +113,20 @@ public class InsetsSourceConsumer { InsetsState.typeToString(control.getType()), mController.getHost().getRootViewTitle())); } - // We are loosing control if (mSourceControl == null) { + // We are loosing control mController.notifyControlRevoked(this); - // Restore server visibility. - mState.getSource(getType()).setVisible( - mController.getLastDispatchedState().getSource(getType()).isVisible()); + // Check if we need to restore server visibility. + final InsetsSource source = mState.getSource(mType); + final boolean serverVisibility = + mController.getLastDispatchedState().getSourceOrDefaultVisibility(mType); + if (source.isVisible() != serverVisibility) { + source.setVisible(serverVisibility); + mController.notifyVisibilityChanged(); + } + + // For updateCompatSysUiVisibility applyLocalVisibilityOverride(); } else { // We are gaining control, and need to run an animation since previous state