From 8ed86598b8e5ee2ef1bf1f69e467489e620635e0 Mon Sep 17 00:00:00 2001 From: Anton Ivanov Date: Thu, 20 Feb 2025 11:52:50 -0800 Subject: Revert^2 "Harden construction sites of android::StrongPointer." This reverts commit f73db7a6242e297ead71df0d0d1fb3a8515245d3. Reason for revert: Scope restricted to sp<>::make which is a safe replacement for assignment from new. Bug: 393217449 Test: ChoreographerTests pass locally. Flag: EXEMPT_refactor Change-Id: I9a38c54c06cc64da099d282c05ccf20f40b70a72 --- libs/gui/SurfaceComposerClient.cpp | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) (limited to 'libs/gui/SurfaceComposerClient.cpp') diff --git a/libs/gui/SurfaceComposerClient.cpp b/libs/gui/SurfaceComposerClient.cpp index df57b275c5..bb7184f9db 100644 --- a/libs/gui/SurfaceComposerClient.cpp +++ b/libs/gui/SurfaceComposerClient.cpp @@ -123,7 +123,7 @@ bool ComposerService::connectLocked() { explicit DeathObserver(ComposerService& mgr) : mComposerService(mgr) { } }; - mDeathObserver = new DeathObserver(*const_cast(this)); + mDeathObserver = sp::make(*const_cast(this)); IInterface::asBinder(mComposerService)->linkToDeath(mDeathObserver); return true; } @@ -170,7 +170,7 @@ bool ComposerServiceAIDL::connectLocked() { explicit DeathObserver(ComposerServiceAIDL& mgr) : mComposerService(mgr) {} }; - mDeathObserver = new DeathObserver(*const_cast(this)); + mDeathObserver = sp::make(*const_cast(this)); IInterface::asBinder(mComposerService)->linkToDeath(mDeathObserver); return true; } @@ -202,7 +202,7 @@ public: DefaultComposerClient& dc = DefaultComposerClient::getInstance(); Mutex::Autolock _l(dc.mLock); if (dc.mClient == nullptr) { - dc.mClient = new SurfaceComposerClient; + dc.mClient = sp::make(); } return dc.mClient; } @@ -399,7 +399,7 @@ void TransactionCompletedListener::setInstance(const sp TransactionCompletedListener::getInstance() { std::lock_guard lock(sListenerInstanceMutex); if (sInstance == nullptr) { - sInstance = new TransactionCompletedListener; + sInstance = sp::make(); } return sInstance; } @@ -691,7 +691,7 @@ TransactionCompletedListener::addTrustedPresentationCallback(TrustedPresentation std::scoped_lock lock(mMutex); mTrustedPresentationCallbacks[id] = std::tuple(tpc, context); - return new SurfaceComposerClient::PresentationCallbackRAII(this, id); + return sp::make(this, id); } void TransactionCompletedListener::clearTrustedPresentationCallback(int id) { @@ -743,7 +743,7 @@ void removeDeadBufferCallback(void* /*context*/, uint64_t graphicBufferId); */ class BufferCache : public Singleton { public: - BufferCache() : token(new BBinder()) {} + BufferCache() : token(sp::make()) {} sp getToken() { return IInterface::asBinder(TransactionCompletedListener::getIInstance()); @@ -1357,7 +1357,7 @@ status_t SurfaceComposerClient::Transaction::apply(bool synchronous, bool oneWay return binderStatus; } -sp SurfaceComposerClient::Transaction::sApplyToken = new BBinder(); +sp SurfaceComposerClient::Transaction::sApplyToken = sp::make(); std::mutex SurfaceComposerClient::Transaction::sApplyTokenMutex; @@ -2683,9 +2683,9 @@ status_t SurfaceComposerClient::createSurfaceChecked(const String8& name, uint32 } ALOGE_IF(err, "SurfaceComposerClient::createSurface error %s", strerror(-err)); if (err == NO_ERROR) { - *outSurface = new SurfaceControl(this, result.handle, result.layerId, - toString(result.layerName), w, h, format, - result.transformHint, flags); + *outSurface = sp::make(this, result.handle, result.layerId, + toString(result.layerName), w, h, format, + result.transformHint, flags); } } return err; @@ -2701,7 +2701,8 @@ sp SurfaceComposerClient::mirrorSurface(SurfaceControl* mirrorFr const binder::Status status = mClient->mirrorSurface(mirrorFromHandle, &result); const status_t err = statusTFromBinderStatus(status); if (err == NO_ERROR) { - return new SurfaceControl(this, result.handle, result.layerId, toString(result.layerName)); + return sp::make(this, result.handle, result.layerId, + toString(result.layerName)); } return nullptr; } @@ -2711,7 +2712,8 @@ sp SurfaceComposerClient::mirrorDisplay(DisplayId displayId) { const binder::Status status = mClient->mirrorDisplay(displayId.value, &result); const status_t err = statusTFromBinderStatus(status); if (err == NO_ERROR) { - return new SurfaceControl(this, result.handle, result.layerId, toString(result.layerName)); + return sp::make(this, result.handle, result.layerId, + toString(result.layerName)); } return nullptr; } -- cgit v1.2.3-59-g8ed1b