Destroy dim layer in transaction.

Currently the destroy is done outside a transaction, causing the layer
to get destroyed while the animation is still holding a reference to it.
Instead, call destroy in the transaction to ensure the destroy executes
with the other transaction requests that occur at the end of the
animation.

Specifically, the reparent was occurring after the destroy completed,
causing the surface to get reparented and remain around forever.

Change-Id: I72c2a6f2a67673fdc2047d78b02a299f64fc44a0
Fixes: 117401895
Test: Repro steps from bug
Test: DimmerTests
diff --git a/services/core/java/com/android/server/wm/Dimmer.java b/services/core/java/com/android/server/wm/Dimmer.java
index 65c8e96..8a660e2 100644
--- a/services/core/java/com/android/server/wm/Dimmer.java
+++ b/services/core/java/com/android/server/wm/Dimmer.java
@@ -126,9 +126,10 @@
         DimState(SurfaceControl dimLayer) {
             mDimLayer = dimLayer;
             mDimming = true;
-            mSurfaceAnimator = new SurfaceAnimator(new DimAnimatable(dimLayer), () -> {
+            final DimAnimatable dimAnimatable = new DimAnimatable(dimLayer);
+            mSurfaceAnimator = new SurfaceAnimator(dimAnimatable, () -> {
                 if (!mDimming) {
-                    mDimLayer.destroy();
+                    dimAnimatable.getPendingTransaction().destroy(mDimLayer);
                 }
             }, mHost.mService);
         }