Reattach LauncherAppWidgetHostView to its parent after canceling drag

onDrop isn't called if the drag is canceled at Launcher.onPause. Let's
also reattach LauncherAppWidgetHostView to its parent in this case.

Test: long press and hold a widget and, at the same time, press the
      power button. Don't let go of the long press and press the power
      button. No crash observed.
Fix: 190950646
Change-Id: Id52a51291863b7ef63c861eb6dc23b015484be65
diff --git a/src/com/android/launcher3/Workspace.java b/src/com/android/launcher3/Workspace.java
index 2e1cc58..303bb01 100644
--- a/src/com/android/launcher3/Workspace.java
+++ b/src/com/android/launcher3/Workspace.java
@@ -2791,6 +2791,10 @@
                 removeWorkspaceItem(mDragInfo.cell);
             }
         } else if (mDragInfo != null) {
+            // When drag is cancelled, reattach content view back to its original parent.
+            if (mDragInfo.cell instanceof LauncherAppWidgetHostView) {
+                d.dragView.detachContentView(/* reattachToPreviousParent= */ true);
+            }
             final CellLayout cellLayout = mLauncher.getCellLayout(
                     mDragInfo.container, mDragInfo.screenId);
             if (cellLayout != null) {