Don't stash immediately when drag was canceled

Instead, keep the taskbar open for the normal timeout.

Test: Drag an app from taskbar and drop back in taskbar, ensure taskbar
stays open until 5 second timeout; Drag an app from taskbar and drop
into split screen, ensure taskbar stashes immediately
Flag: ENABLE_TRANSIENT_TASKBAR true
Fixes: 275019813

Change-Id: I06ca0eccbfe313dbae8f6d96c7c09bb659f6a27b
diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarDragController.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarDragController.java
index 6c9ab0c..66a903b 100644
--- a/quickstep/src/com/android/launcher3/taskbar/TaskbarDragController.java
+++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarDragController.java
@@ -457,9 +457,12 @@
             mControllers.taskbarAutohideSuspendController.updateFlag(
                     TaskbarAutohideSuspendController.FLAG_AUTOHIDE_SUSPEND_DRAGGING, false);
             mActivity.onDragEnd();
-            // Note, this must be done last to ensure no AutohideSuspendFlags are active, as that
-            // will prevent us from stashing until the timeout.
-            mControllers.taskbarStashController.updateAndAnimateTransientTaskbar(true);
+            if (mReturnAnimator == null) {
+                // Upon successful drag, immediately stash taskbar.
+                // Note, this must be done last to ensure no AutohideSuspendFlags are active, as
+                // that will prevent us from stashing until the timeout.
+                mControllers.taskbarStashController.updateAndAnimateTransientTaskbar(true);
+            }
         }
     }
 
@@ -493,8 +496,9 @@
                     callOnDragEnd();
                     dragView.remove();
                     dragView.clearAnimation();
+                    // Do this after callOnDragEnd(), because we use mReturnAnimator != null to
+                    // imply the drag was canceled rather than successful.
                     mReturnAnimator = null;
-
                 }
             });
             mReturnAnimator.start();
@@ -556,6 +560,8 @@
                 syncGroup.add(viewRoot, null /* runnable */);
                 syncGroup.addTransaction(transaction);
                 syncGroup.markSyncReady();
+                // Do this after maybeOnDragEnd(), because we use mReturnAnimator != null to imply
+                // the drag was canceled rather than successful.
                 mReturnAnimator = null;
             }
         });