SF: use shared_ptr to track hwcLayer

Use std::shared_ptr to track hwcLayer pointers.
This is necessary because the calculation of
data for HWComposer is done in Layer and the processing of that
data is done in SurfaceFlinger, and we need to make sure that
the hwcLayer is not destroyed by Layer while or before being
used by SurfaceFlinger.

Bug: 112259502
Test: cts -m CtsViewTestCases
      SurfaceFlinger_test
      vrflinger_test

Change-Id: I683dd071efbeebd9a9941053183daf4efb88469e
diff --git a/services/surfaceflinger/Layer.h b/services/surfaceflinger/Layer.h
index a48cdff..a6da495 100644
--- a/services/surfaceflinger/Layer.h
+++ b/services/surfaceflinger/Layer.h
@@ -510,7 +510,7 @@
         if (getBE().mHwcLayers.count(displayId) == 0) {
             return nullptr;
         }
-        return getBE().mHwcLayers[displayId].layer;
+        return getBE().mHwcLayers[displayId].layer.get();
     }
 
     // -----------------------------------------------------------------------