Fix memory leak where SC for drag is never released

Steps: Finish DnD from any app and check `adb shell dumpsys SurfaceFlinger`
Observation: Drag surface remanined even after force GC, but got cleared
on "Force stop" or "killing" the client app that started drag.

Some things observed in debugging: When passing surface control over
binder, a new native object ptr was created so releasing the received SC
doesn't mean the sent SC is also cleared. So, need to release local
variables as well to ensure no memory leak.

Bug: 314059463
Test: manual
Change-Id: Id45bcf5c7a243a5e9c5dde33138c74089f1deb28
diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java
index c98d1d7..59398e7 100644
--- a/core/java/android/view/View.java
+++ b/core/java/android/view/View.java
@@ -28492,6 +28492,7 @@
                 surface.destroy();
             }
             session.kill();
+            surfaceControl.release();
         }
     }
 
diff --git a/services/core/java/com/android/server/wm/DragDropController.java b/services/core/java/com/android/server/wm/DragDropController.java
index 32d60c5..6a3cf43 100644
--- a/services/core/java/com/android/server/wm/DragDropController.java
+++ b/services/core/java/com/android/server/wm/DragDropController.java
@@ -469,8 +469,7 @@
 
                 case MSG_REMOVE_DRAG_SURFACE_TIMEOUT: {
                     synchronized (mService.mGlobalLock) {
-                        mService.mTransactionFactory.get()
-                                .reparent((SurfaceControl) msg.obj, null).apply();
+                        mService.mTransactionFactory.get().remove((SurfaceControl) msg.obj).apply();
                     }
                     break;
                 }
diff --git a/services/core/java/com/android/server/wm/DragState.java b/services/core/java/com/android/server/wm/DragState.java
index adbe3bc..d302f06 100644
--- a/services/core/java/com/android/server/wm/DragState.java
+++ b/services/core/java/com/android/server/wm/DragState.java
@@ -270,7 +270,7 @@
         }
         if (mSurfaceControl != null) {
             if (!mRelinquishDragSurfaceToDropTarget && !relinquishDragSurfaceToDragSource()) {
-                mTransaction.reparent(mSurfaceControl, null).apply();
+                mTransaction.remove(mSurfaceControl).apply();
             } else {
                 mDragDropController.sendTimeoutMessage(MSG_REMOVE_DRAG_SURFACE_TIMEOUT,
                         mSurfaceControl, DragDropController.DRAG_TIMEOUT_MS);