Harden construction sites of android::StrongPointer.
Bug: 393217449
Test: presubmit
Flag: EXEMPT_refactor
Change-Id: Icf703aed608531e9b302b299481af00a52074731
diff --git a/libs/gui/SurfaceControl.cpp b/libs/gui/SurfaceControl.cpp
index b735418..ba2d80d 100644
--- a/libs/gui/SurfaceControl.cpp
+++ b/libs/gui/SurfaceControl.cpp
@@ -269,10 +269,11 @@
SAFE_PARCEL(parcel.readUint32, &format);
// We aren't the original owner of the surface.
- *outSurfaceControl = new SurfaceControl(new SurfaceComposerClient(
- interface_cast<ISurfaceComposerClient>(client)),
- handle.get(), layerId, layerName, width, height, format,
- transformHint);
+ *outSurfaceControl =
+ sp<SurfaceControl>::make(sp<SurfaceComposerClient>::make(
+ interface_cast<ISurfaceComposerClient>(client)),
+ handle, layerId, layerName, width, height, format,
+ transformHint);
return NO_ERROR;
}
@@ -303,7 +304,7 @@
if (mBbqChild != nullptr) {
return mBbqChild;
}
- return this;
+ return sp<SurfaceControl>::fromExisting(this);
}
uint64_t SurfaceControl::resolveFrameNumber(const std::optional<uint64_t>& frameNumber) {