From 9b46c463ad0b65aca0c3a4fd3c765eed5ec583de Mon Sep 17 00:00:00 2001 From: Fengjiang Li Date: Thu, 4 Apr 2024 12:15:17 -0700 Subject: [PATCH] [1/2] Fix resize frame showing at left top corner of workspace. Some widget will show config activity and immediately dismiss it after user dropping widget onto workspace. This lead to 2 code paths triggered around same time: 1. Drop widget to workspace and show resize frame, after state is transitiion to NORMAL, show workspace 2. Close config activity and Launcher#onActivityResult, which triggers removing dropped widget and extract bitmap, then re-inflate another pending widget and show resize frame Due to race condition between #1 and #2, we might remove the dropped widget first in #2, then show resize frame in #1 after workspace is transitione to NORMAL, leading showing resize frame at incorrect location Next CL will fix the slight misalignment of resize frame with widget. Bug: 331433240 Flag: NONE Test: manual Change-Id: Ie02f59b370271d517ed2e91b42d665f44a86095b --- src/com/android/launcher3/AppWidgetResizeFrame.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/com/android/launcher3/AppWidgetResizeFrame.java b/src/com/android/launcher3/AppWidgetResizeFrame.java index 4a277f0ed5..af3fdcc69a 100644 --- a/src/com/android/launcher3/AppWidgetResizeFrame.java +++ b/src/com/android/launcher3/AppWidgetResizeFrame.java @@ -200,6 +200,10 @@ public class AppWidgetResizeFrame extends AbstractFloatingView implements View.O } public static void showForWidget(LauncherAppWidgetHostView widget, CellLayout cellLayout) { + // If widget is not added to view hierarchy, we cannot show resize frame at correct location + if (widget.getParent() == null) { + return; + } Launcher launcher = Launcher.getLauncher(cellLayout.getContext()); AbstractFloatingView.closeAllOpenViews(launcher);