From 511e68bd64115751c929dd86323f2d4765068a37 Mon Sep 17 00:00:00 2001 From: Ming-Shin Lu Date: Sat, 11 Dec 2021 02:07:40 +0800 Subject: [PATCH] Ensure Insets surface visiblity and alpha value are aligned In case somehow when the client getting the leash from InsetsSourceConsumer#setControl to just applying the leash surface as visible directly without animating, but still invisible to user because of the zero alpha value. Bug: 209064170 Test: manual as test steps: 1) enable shell transitions (adb shell setprop persist.debug.shell_transit 1 + reboot) 2) In home screen, open camera 3) Back gesture to back home 4) Expect the status bar is visible when backing to home Change-Id: Iaacdf5f57e68b928e2a19036cbd8a137cf320497 --- core/java/android/view/InsetsSourceConsumer.java | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/core/java/android/view/InsetsSourceConsumer.java b/core/java/android/view/InsetsSourceConsumer.java index bf9de39124c94..b1582cf9f0231 100644 --- a/core/java/android/view/InsetsSourceConsumer.java +++ b/core/java/android/view/InsetsSourceConsumer.java @@ -180,10 +180,7 @@ public class InsetsSourceConsumer { // If we have a new leash, make sure visibility is up-to-date, even though we // didn't want to run an animation above. - SurfaceControl newLeash = mSourceControl.getLeash(); - if (oldLeash == null || newLeash == null || !oldLeash.isSameSurface(newLeash)) { - applyHiddenToControl(); - } + applyRequestedVisibilityToControl(); // Remove the surface that owned by last control when it lost. if (!requestedVisible && !mIsAnimationPending && lastControl == null) { @@ -388,18 +385,20 @@ public class InsetsSourceConsumer { } } - private void applyHiddenToControl() { + private void applyRequestedVisibilityToControl() { if (mSourceControl == null || mSourceControl.getLeash() == null) { return; } final Transaction t = mTransactionSupplier.get(); - if (DEBUG) Log.d(TAG, "applyHiddenToControl: " + mRequestedVisible); + if (DEBUG) Log.d(TAG, "applyRequestedVisibilityToControl: " + mRequestedVisible); if (mRequestedVisible) { t.show(mSourceControl.getLeash()); } else { t.hide(mSourceControl.getLeash()); } + // Ensure the alpha value is aligned with the actual requested visibility. + t.setAlpha(mSourceControl.getLeash(), mRequestedVisible ? 1 : 0); t.apply(); onPerceptible(mRequestedVisible); }