Revert "Layer: Use raw pointers for Current/Drawing parent"

This reverts commit cbdb79a195e6c690e16948a7e7c3abbd36414b17.

Bug: 203175614
Bug: 203559094
Change-Id: I5432ad46bfbbe5a009e3fb72ae7ac129263260ce
diff --git a/services/surfaceflinger/Layer.h b/services/surfaceflinger/Layer.h
index 07b2eb5..8209c51 100644
--- a/services/surfaceflinger/Layer.h
+++ b/services/surfaceflinger/Layer.h
@@ -795,12 +795,12 @@
     // Returns index if removed, or negative value otherwise
     // for symmetry with Vector::remove
     ssize_t removeChild(const sp<Layer>& layer);
+    sp<Layer> getParent() const { return mCurrentParent.promote(); }
 
     // Should be called with the surfaceflinger statelock held
     bool isAtRoot() const { return mIsAtRoot; }
     void setIsAtRoot(bool isAtRoot) { mIsAtRoot = isAtRoot; }
 
-    Layer* getParent() const { return mCurrentParent; }
     bool hasParent() const { return getParent() != nullptr; }
     Rect getScreenBounds(bool reduceTransparentRegion = true) const;
     bool setChildLayer(const sp<Layer>& childLayer, int32_t z);
@@ -1007,8 +1007,8 @@
     LayerVector mCurrentChildren{LayerVector::StateSet::Current};
     LayerVector mDrawingChildren{LayerVector::StateSet::Drawing};
 
-    Layer* mCurrentParent = nullptr;
-    Layer* mDrawingParent = nullptr;
+    wp<Layer> mCurrentParent;
+    wp<Layer> mDrawingParent;
 
     // Window types from WindowManager.LayoutParams
     const gui::WindowInfo::Type mWindowType;