Fixing PendingWidgets getting attached to real host

Bug: 318539160
Flag: aconfig enable_workspace_inflation DISABLED
Test: TaplBindWidgetTest#testPendingWidget_notRestored_activeInstall
Change-Id: I013811e83b90ea32221904a27790dd677dd63b4b
This commit is contained in:
Sunny Goyal
2024-03-15 10:15:29 -07:00
parent 00711e68a5
commit d51f91a7d0
@@ -349,7 +349,13 @@ public class LauncherWidgetHolder {
@NonNull
public final AppWidgetHostView attachViewToHostAndGetAttachedView(
@NonNull LauncherAppWidgetHostView view) {
if (mViews.get(view.getAppWidgetId()) != view) {
// Binder can also inflate placeholder widgets in case of backup-restore. Skip
// attaching such widgets
boolean isRealWidget = ((view instanceof PendingAppWidgetHostView pw)
? pw.isDeferredWidget() : true)
&& view.getAppWidgetInfo() != null;
if (isRealWidget && mViews.get(view.getAppWidgetId()) != view) {
view = recycleExistingView(view);
mViews.put(view.getAppWidgetId(), view);
}