Merge "Replace consumeNextDraw with SurfaceSyncer" into tm-dev
diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarDragController.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarDragController.java
index e2ab443..9ba4a65 100644
--- a/quickstep/src/com/android/launcher3/taskbar/TaskbarDragController.java
+++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarDragController.java
@@ -36,6 +36,7 @@
 import android.view.SurfaceControl;
 import android.view.View;
 import android.view.ViewRootImpl;
+import android.window.SurfaceSyncer;
 
 import androidx.annotation.Nullable;
 
@@ -476,6 +477,7 @@
                 tx.setScale(dragSurface, scale, scale);
                 tx.setAlpha(dragSurface, alpha);
                 tx.apply();
+                tx.close();
             }
         });
         mReturnAnimator.addListener(new AnimatorListenerAdapter() {
@@ -499,12 +501,14 @@
                 maybeOnDragEnd();
                 // Synchronize removing the drag surface with the next draw after calling
                 // maybeOnDragEnd()
-                viewRoot.consumeNextDraw((transaction) -> {
-                    transaction.remove(dragSurface);
-                    transaction.apply();
-                    tx.close();
-                });
-                viewRoot.getView().invalidate();
+                SurfaceControl.Transaction transaction = new SurfaceControl.Transaction();
+                transaction.remove(dragSurface);
+                SurfaceSyncer syncer = new SurfaceSyncer();
+                int syncId = syncer.setupSync(transaction::close);
+                syncer.addToSync(syncId, viewRoot.getView());
+                syncer.addTransactionToSync(syncId, transaction);
+                syncer.markSyncReady(syncId);
+
                 mReturnAnimator = null;
             }
         });