Merge "Fix Overlapping notifications when the swiping out is canceled" into main
diff --git a/packages/SystemUI/src/com/android/systemui/SwipeHelper.java b/packages/SystemUI/src/com/android/systemui/SwipeHelper.java
index 954129e..22bd207 100644
--- a/packages/SystemUI/src/com/android/systemui/SwipeHelper.java
+++ b/packages/SystemUI/src/com/android/systemui/SwipeHelper.java
@@ -18,8 +18,8 @@
 
 import static androidx.dynamicanimation.animation.DynamicAnimation.TRANSLATION_X;
 import static androidx.dynamicanimation.animation.FloatPropertyCompat.createFloatPropertyCompat;
-
 import static com.android.systemui.classifier.Classifier.NOTIFICATION_DISMISS;
+import static com.android.systemui.flags.Flags.SWIPE_UNCLEARED_TRANSIENT_VIEW_FIX;
 import static com.android.systemui.statusbar.notification.NotificationUtils.logKey;
 
 import android.animation.Animator;
@@ -482,7 +482,14 @@
                 boolean wasRemoved = false;
                 if (animView instanceof ExpandableNotificationRow) {
                     ExpandableNotificationRow row = (ExpandableNotificationRow) animView;
-                    wasRemoved = row.isRemoved();
+                    if (mFeatureFlags.isEnabled(SWIPE_UNCLEARED_TRANSIENT_VIEW_FIX)) {
+                        // If the view is already removed from its parent and added as Transient,
+                        // we need to clean the transient view upon animation end
+                        wasRemoved = row.getTransientContainer() != null
+                            || row.getParent() == null || row.isRemoved();
+                    } else {
+                        wasRemoved = row.isRemoved();
+                    }
                 }
                 if (!mCancelled || wasRemoved) {
                     mCallback.onChildDismissed(animView);