Don't lose transaction callbacks that are still in the drawing state.

When a message invalidate occurs, the current state will be copied into
drawing state. If another invalide occurs before a refresh, the new
current state will be copied into the drawing state. That means we
would lose any transaction callbacks that were sent with the first
transaction. When refresh is called, we will not notify the callbacks
from the first transaction and the system will get stuck waiting for
callbacks forever.

Test: No direct steps to reproduce. Open apps a lot with blast and
make sure system doesn't freeze.

Change-Id: I820027e86b15e082e5e7092b2ee52e90a2328d38
diff --git a/services/surfaceflinger/Layer.cpp b/services/surfaceflinger/Layer.cpp
index 50707df..f657a00 100644
--- a/services/surfaceflinger/Layer.cpp
+++ b/services/surfaceflinger/Layer.cpp
@@ -1034,6 +1034,12 @@
         mCurrentState.inputInfoChanged = false;
     }
 
+    // Add the callbacks from the drawing state into the current state. This is so when the current
+    // state gets copied to drawing, we don't lose the callback handles that are still in drawing.
+    for (auto& handle : s.callbackHandles) {
+        c.callbackHandles.push_back(handle);
+    }
+
     // Commit the transaction
     commitTransaction(c);
     mPendingStatesSnapshot = mPendingStates;