From a82a7dc205644b7ee2f1b13f98850d463e103373 Mon Sep 17 00:00:00 2001 From: Jon Miranda Date: Tue, 10 May 2022 11:48:32 -0700 Subject: [PATCH] Clear all DragView in onResume - Multiple users reports view getting stuck on screen. This CL clears all DragView when user leaves launcher. - Moved to onResume to not interfere with start up time, and also aligned with when we remove AbstractFloatingView. - Root cause still undetermined, but happens enough that it warrants a temp fix. Bug: 162636845 Test: drag and drop configurable widget (widget that gets dropped then opens up a configuration activity) Change-Id: I532b5274a1308c53f67c23c5c8ca07f2b7f9802c --- src/com/android/launcher3/Launcher.java | 1 + src/com/android/launcher3/dragndrop/DragView.java | 15 +++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java index ad87451fa9..135b88d5b7 100644 --- a/src/com/android/launcher3/Launcher.java +++ b/src/com/android/launcher3/Launcher.java @@ -1169,6 +1169,7 @@ public class Launcher extends StatefulActivity } AbstractFloatingView.closeAllOpenViewsExcept(this, false, TYPE_REBIND_SAFE); + DragView.removeAllViews(this); TraceHelper.INSTANCE.endSection(traceToken); } diff --git a/src/com/android/launcher3/dragndrop/DragView.java b/src/com/android/launcher3/dragndrop/DragView.java index a3945fdba8..0264ae21be 100644 --- a/src/com/android/launcher3/dragndrop/DragView.java +++ b/src/com/android/launcher3/dragndrop/DragView.java @@ -578,4 +578,19 @@ public abstract class DragView extends Fram iv.setImageDrawable(drawable); return iv; } + + /** + * Removes any stray DragView from the DragLayer. + */ + public static void removeAllViews(ActivityContext activity) { + BaseDragLayer dragLayer = activity.getDragLayer(); + // Iterate in reverse order. DragView is added later to the dragLayer, + // and will be one of the last views. + for (int i = dragLayer.getChildCount() - 1; i >= 0; i--) { + View child = dragLayer.getChildAt(i); + if (child instanceof DragView) { + dragLayer.removeView(child); + } + } + } }