From ae3b07716119794a7c5d0f6ea127c29c428979ba Mon Sep 17 00:00:00 2001 From: Vishnu Nair Date: Thu, 19 Mar 2020 16:55:25 -0700 Subject: [PATCH] Update shadow radius if the task has no visible children Test: enter pip and lock phone, then unlock phone Test: go/wm-smoke Fixes: 150461623 Change-Id: I9cba48527e29c6acb9139689c0e3fd3e42ffd955 --- .../core/java/com/android/server/wm/Task.java | 40 +++++++++++++------ 1 file changed, 27 insertions(+), 13 deletions(-) diff --git a/services/core/java/com/android/server/wm/Task.java b/services/core/java/com/android/server/wm/Task.java index f826deb6926a6..569d64cf4f398 100644 --- a/services/core/java/com/android/server/wm/Task.java +++ b/services/core/java/com/android/server/wm/Task.java @@ -1918,7 +1918,6 @@ class Task extends WindowContainer { super.onConfigurationChanged(newParentConfig); if (wasInMultiWindowMode != inMultiWindowMode()) { mStackSupervisor.scheduleUpdateMultiWindowMode(this); - updateShadowsRadius(isFocused(), getPendingTransaction()); } final int newWinMode = getWindowingMode(); @@ -3320,6 +3319,7 @@ class Task extends WindowContainer { } updateSurfaceCrop(); + updateShadowsRadius(isFocused(), getPendingTransaction()); if (mDimmer.updateDims(getPendingTransaction(), mTmpDimBoundsRect)) { scheduleAnimation(); @@ -4140,27 +4140,41 @@ class Task extends WindowContainer { return mDisplayContent.mCurrentFocus.getTask() == this; } + /** + * @return true if the task is visible and has at least one visible child. + */ + private boolean hasVisibleChildren() { + if (!isAttached() || isForceHidden()) { + return false; + } + + return getActivity(ActivityRecord::isVisible) != null; + } + /** * @return the desired shadow radius in pixels for the current task. */ private float getShadowRadius(boolean taskIsFocused) { - if (mDisplayContent == null) { + int elevation = 0; + + // Get elevation for a specific windowing mode. + if (inPinnedWindowingMode()) { + elevation = PINNED_WINDOWING_MODE_ELEVATION_IN_DIP; + } else if (ENABLE_FREEFORM_COMPOSITOR_SHADOWS && inFreeformWindowingMode()) { + // TODO(b/149585281) remove when root task has the correct bounds for freeform + elevation = taskIsFocused + ? DECOR_SHADOW_FOCUSED_HEIGHT_IN_DIP : DECOR_SHADOW_UNFOCUSED_HEIGHT_IN_DIP; + } else { + // For all other windowing modes, do not draw a shadow. return 0; } - if (inPinnedWindowingMode()) { - return dipToPixel(PINNED_WINDOWING_MODE_ELEVATION_IN_DIP, - mDisplayContent.getDisplayMetrics()); - } - // TODO(b/149585281) remove when root task has the correct bounds for freeform - if (ENABLE_FREEFORM_COMPOSITOR_SHADOWS && inFreeformWindowingMode()) { - final int elevation = taskIsFocused - ? DECOR_SHADOW_FOCUSED_HEIGHT_IN_DIP : DECOR_SHADOW_UNFOCUSED_HEIGHT_IN_DIP; - return dipToPixel(elevation, mDisplayContent.getDisplayMetrics()); + // If the task has no visible children, do not draw a shadow. + if (!hasVisibleChildren()) { + return 0; } - // For all other windowing modes, do not draw a shadow. - return 0; + return dipToPixel(elevation, getDisplayContent().getDisplayMetrics()); } /**