Do not drop MonitoredProducer in binder calls

Currently the MonitoredProducer is left out when the producer is
marshalled for binder calls. If others than the owning layer have
references to the underlying surface, clearing the layer leads to the
surface being removed from the SF tracking list. This is in clear
contradiction with the test case
libgui_test.SurfaceTest#QueuesToWindowComposerIsTrueWhenPurgatorized.

Unfortunately the test case has not accounted for the async nature of
the operation and has been only intermittently failing for a long
while. Change also changes the test to wait for the clear operation to
complete.

Test: libgui_test, AUPT on Pixel XL
Bug: 31045556
Change-Id: Iddb1cef82c492e8b3beeb32de7e11587e0c1ebed
diff --git a/libs/gui/tests/Surface_test.cpp b/libs/gui/tests/Surface_test.cpp
index 1aa03a5..66e1bb6 100644
--- a/libs/gui/tests/Surface_test.cpp
+++ b/libs/gui/tests/Surface_test.cpp
@@ -29,8 +29,12 @@
 #include <private/gui/ComposerService.h>
 #include <binder/ProcessState.h>
 
+#include <thread>
+
 namespace android {
 
+using namespace std::chrono_literals;
+
 class SurfaceTest : public ::testing::Test {
 protected:
 
@@ -77,6 +81,8 @@
 
 TEST_F(SurfaceTest, QueuesToWindowComposerIsTrueWhenPurgatorized) {
     mSurfaceControl.clear();
+    // Wait for the async clean-up to complete.
+    std::this_thread::sleep_for(50ms);
 
     sp<ANativeWindow> anw(mSurface);
     int result = -123;