surfaceflinger: clear HWC layers in Layer::onRemoved

Explicitly destroy HWC layers in Layer::onRemoved rather than doing
that implicitly in the destructor.  The layer may be destructed by
any thread that holds a sp<Layer>, but only the main thread should
talk to the composer.

Bug: 38151478
Bug: 37978067
Test: manual
Change-Id: If6fcfaa5a70d247b751f2b4d9aec9eca890e3aa5
diff --git a/services/surfaceflinger/Layer.cpp b/services/surfaceflinger/Layer.cpp
index 06a0765..89ba2ee 100644
--- a/services/surfaceflinger/Layer.cpp
+++ b/services/surfaceflinger/Layer.cpp
@@ -296,6 +296,9 @@
     }
 
     mSurfaceFlingerConsumer->abandon();
+
+    clearHwcLayers();
+
     for (const auto& child : mCurrentChildren) {
         child->onRemoved();
     }