Fix the shadow problem caused by layer parent switching

When the parent of a layer changes, shadowRadius should
not be directly passed in the computBounds here.

When the layer's parent changes, for example, open an app
in freeform. If the app exits the current ActivityRecord, it will
trigger the recent task request screen capture of the
current app, temporarily switch the task of the app to
"Screenshot Parent", and then switch back. This operation
will cause the shadow of the task to be passed to the children layers
through CanDrawShadows, i.e., the shadow of non Container layer
is wrongly passed to its children layers.
Therefore, there is a problem in shadow drawing.

We should judge whether shadowRadius needs to be passed
at this time through CanDrawShadows. If not, pass 0.f.

Otherwise, the shadow will be painted repeatedly.

bug:215476160 in partnerissuetracker

Signed-off-by: xinying1 <xinying1@xiaomi.corp-partner.google.com>
Change-Id: Id4b6c8bcc79aa68f96d0c4c655ea853361ed1e7c
diff --git a/services/surfaceflinger/Layer.cpp b/services/surfaceflinger/Layer.cpp
index da7ff71..f94917c 100644
--- a/services/surfaceflinger/Layer.cpp
+++ b/services/surfaceflinger/Layer.cpp
@@ -1608,8 +1608,10 @@
 void Layer::setChildrenDrawingParent(const sp<Layer>& newParent) {
     for (const sp<Layer>& child : mDrawingChildren) {
         child->mDrawingParent = newParent;
+        const float parentShadowRadius =
+                newParent->canDrawShadows() ? 0.f : newParent->mEffectiveShadowRadius;
         child->computeBounds(newParent->mBounds, newParent->mEffectiveTransform,
-                             newParent->mEffectiveShadowRadius);
+                             parentShadowRadius);
     }
 }