SurfaceFlinger: Emit callbacks for non-buffer layer transactions

Ensure we emit callbacks if the transaction contains only non-buffer
layer state changes.

Test: atest SurfaceFlinger_test
Fixes: 205183085
Change-Id: I56bf0dcaff4312628fe2cd1d0b93db520518ec54
diff --git a/services/surfaceflinger/BufferStateLayer.cpp b/services/surfaceflinger/BufferStateLayer.cpp
index c213570..3e09a40 100644
--- a/services/surfaceflinger/BufferStateLayer.cpp
+++ b/services/surfaceflinger/BufferStateLayer.cpp
@@ -549,13 +549,19 @@
 }
 
 bool BufferStateLayer::setTransactionCompletedListeners(
-        const std::vector<sp<CallbackHandle>>& handles) {
+        const std::vector<ListenerCallbacks>& listenerCallbacks, const sp<IBinder>& layerHandle) {
     // If there is no handle, we will not send a callback so reset mReleasePreviousBuffer and return
-    if (handles.empty()) {
+    if (listenerCallbacks.empty()) {
         mReleasePreviousBuffer = false;
         return false;
     }
 
+    std::vector<sp<CallbackHandle>> handles;
+    handles.reserve(listenerCallbacks.size());
+    for (auto& [listener, callbackIds] : listenerCallbacks) {
+        handles.emplace_back(new CallbackHandle(listener, callbackIds, layerHandle));
+    }
+
     const bool willPresent = willPresentCurrentTransaction();
 
     for (const auto& handle : handles) {
@@ -571,9 +577,10 @@
             // Store so latched time and release fence can be set
             mDrawingState.callbackHandles.push_back(handle);
 
-        } else { // If this layer will NOT need to be relatched and presented this frame
+        } else {
+            // If this layer will NOT need to be relatched and presented this frame
             // Notify the transaction completed thread this handle is done
-            mFlinger->getTransactionCallbackInvoker().registerUnpresentedCallbackHandle(handle);
+            mFlinger->getTransactionCallbackInvoker().addUnpresentedCallbackHandle(handle);
         }
     }