summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Treehugger Robot <android-test-infra-autosubmit@system.gserviceaccount.com> 2025-03-18 08:15:24 -0700
committer Android (Google) Code Review <android-gerrit@google.com> 2025-03-18 08:15:24 -0700
commit969e7ea620148cad0dc103b1df1516b2822ebe3a (patch)
treea6f89249430e2a00cde0e516623f7e32121dae34
parent4b5277998b867b95bd340c09f0c137dc9738f006 (diff)
parent9045666047d55134c2e4f0108a88b5799653003e (diff)
Merge changes I60d42f38,I25857739 into main
* changes: Ensure Choreographer is held as sp<> in SurfaceControl. Harden construction sites of android::StrongPointer in frameworks/native
-rw-r--r--cmds/flatland/GLHelper.cpp2
-rw-r--r--libs/gui/SurfaceControl.cpp4
-rw-r--r--libs/gui/include/gui/SurfaceControl.h6
-rw-r--r--libs/gui/tests/BLASTBufferQueue_test.cpp2
-rw-r--r--libs/gui/tests/DisplayedContentSampling_test.cpp2
-rw-r--r--libs/gui/tests/EndToEndNativeInputTest.cpp2
-rw-r--r--libs/gui/tests/GLTest.cpp2
-rw-r--r--libs/gui/tests/RegionSampling_test.cpp2
-rw-r--r--libs/gui/tests/SamplingDemo.cpp2
-rw-r--r--libs/gui/tests/Surface_test.cpp2
-rw-r--r--opengl/tests/lib/WindowSurface.cpp2
-rw-r--r--services/automotive/display/AutomotiveDisplayProxyService.cpp2
12 files changed, 15 insertions, 15 deletions
diff --git a/cmds/flatland/GLHelper.cpp b/cmds/flatland/GLHelper.cpp
index 6e6d27d463..a2e171fa3b 100644
--- a/cmds/flatland/GLHelper.cpp
+++ b/cmds/flatland/GLHelper.cpp
@@ -241,7 +241,7 @@ bool GLHelper::createWindowSurface(uint32_t w, uint32_t h,
status_t err;
if (mSurfaceComposerClient == nullptr) {
- mSurfaceComposerClient = new SurfaceComposerClient;
+ mSurfaceComposerClient = sp<SurfaceComposerClient>::make();
}
err = mSurfaceComposerClient->initCheck();
if (err != NO_ERROR) {
diff --git a/libs/gui/SurfaceControl.cpp b/libs/gui/SurfaceControl.cpp
index 1eb9b87c3c..50877f8c56 100644
--- a/libs/gui/SurfaceControl.cpp
+++ b/libs/gui/SurfaceControl.cpp
@@ -194,7 +194,7 @@ const std::string& SurfaceControl::getName() const {
return mName;
}
-std::shared_ptr<Choreographer> SurfaceControl::getChoreographer() {
+sp<Choreographer> SurfaceControl::getChoreographer() {
if (mChoreographer) {
return mChoreographer;
}
@@ -203,7 +203,7 @@ std::shared_ptr<Choreographer> SurfaceControl::getChoreographer() {
ALOGE("%s: No looper prepared for thread", __func__);
return nullptr;
}
- mChoreographer = std::make_shared<Choreographer>(looper, getHandle());
+ mChoreographer = sp<Choreographer>::make(looper, getHandle());
status_t result = mChoreographer->initialize();
if (result != OK) {
ALOGE("Failed to initialize choreographer");
diff --git a/libs/gui/include/gui/SurfaceControl.h b/libs/gui/include/gui/SurfaceControl.h
index 344b957ba7..91a422d155 100644
--- a/libs/gui/include/gui/SurfaceControl.h
+++ b/libs/gui/include/gui/SurfaceControl.h
@@ -26,6 +26,7 @@
#include <android/gui/ISurfaceComposerClient.h>
+#include <gui/Choreographer.h>
#include <ui/FrameStats.h>
#include <ui/PixelFormat.h>
#include <ui/Region.h>
@@ -36,7 +37,6 @@ namespace android {
// ---------------------------------------------------------------------------
-class Choreographer;
class IGraphicBufferProducer;
class Surface;
class SurfaceComposerClient;
@@ -82,7 +82,7 @@ public:
const std::string& getName() const;
// TODO(b/267195698): Consider renaming.
- std::shared_ptr<Choreographer> getChoreographer();
+ sp<Choreographer> getChoreographer();
sp<IGraphicBufferProducer> getIGraphicBufferProducer();
@@ -134,7 +134,7 @@ private:
PixelFormat mFormat = PIXEL_FORMAT_NONE;
uint32_t mCreateFlags = 0;
uint64_t mFallbackFrameNumber = 100;
- std::shared_ptr<Choreographer> mChoreographer;
+ sp<Choreographer> mChoreographer;
};
}; // namespace android
diff --git a/libs/gui/tests/BLASTBufferQueue_test.cpp b/libs/gui/tests/BLASTBufferQueue_test.cpp
index b861c6d4b7..4e4c8a2b63 100644
--- a/libs/gui/tests/BLASTBufferQueue_test.cpp
+++ b/libs/gui/tests/BLASTBufferQueue_test.cpp
@@ -201,7 +201,7 @@ public:
protected:
void SetUp() {
mComposer = ComposerService::getComposerService();
- mClient = new SurfaceComposerClient();
+ mClient = sp<SurfaceComposerClient>::make();
const auto ids = SurfaceComposerClient::getPhysicalDisplayIds();
ASSERT_FALSE(ids.empty());
// display 0 is picked as this test is not much display depedent
diff --git a/libs/gui/tests/DisplayedContentSampling_test.cpp b/libs/gui/tests/DisplayedContentSampling_test.cpp
index bffb3f0430..62d73ca752 100644
--- a/libs/gui/tests/DisplayedContentSampling_test.cpp
+++ b/libs/gui/tests/DisplayedContentSampling_test.cpp
@@ -30,7 +30,7 @@ static constexpr uint32_t INVALID_MASK = 0x10;
class DisplayedContentSamplingTest : public ::testing::Test {
protected:
void SetUp() {
- mComposerClient = new SurfaceComposerClient;
+ mComposerClient = sp<SurfaceComposerClient>::make();
ASSERT_EQ(OK, mComposerClient->initCheck());
const auto ids = SurfaceComposerClient::getPhysicalDisplayIds();
ASSERT_FALSE(ids.empty());
diff --git a/libs/gui/tests/EndToEndNativeInputTest.cpp b/libs/gui/tests/EndToEndNativeInputTest.cpp
index adf8fce472..5a5067b2b9 100644
--- a/libs/gui/tests/EndToEndNativeInputTest.cpp
+++ b/libs/gui/tests/EndToEndNativeInputTest.cpp
@@ -398,7 +398,7 @@ public:
InputSurfacesTest() { ProcessState::self()->startThreadPool(); }
void SetUp() {
- mComposerClient = new SurfaceComposerClient;
+ mComposerClient = sp<SurfaceComposerClient>::make();
ASSERT_EQ(NO_ERROR, mComposerClient->initCheck());
const auto ids = SurfaceComposerClient::getPhysicalDisplayIds();
ASSERT_FALSE(ids.empty());
diff --git a/libs/gui/tests/GLTest.cpp b/libs/gui/tests/GLTest.cpp
index 40af8e845a..407c18ed0d 100644
--- a/libs/gui/tests/GLTest.cpp
+++ b/libs/gui/tests/GLTest.cpp
@@ -56,7 +56,7 @@ void GLTest::SetUp() {
}
if (mDisplaySecs > 0) {
- mComposerClient = new SurfaceComposerClient;
+ mComposerClient = sp<SurfaceComposerClient>::make();
ASSERT_EQ(NO_ERROR, mComposerClient->initCheck());
mSurfaceControl = mComposerClient->createSurface(
diff --git a/libs/gui/tests/RegionSampling_test.cpp b/libs/gui/tests/RegionSampling_test.cpp
index c35efe28a3..d80d223f49 100644
--- a/libs/gui/tests/RegionSampling_test.cpp
+++ b/libs/gui/tests/RegionSampling_test.cpp
@@ -180,7 +180,7 @@ protected:
}
void SetUp() override {
- mSurfaceComposerClient = new SurfaceComposerClient;
+ mSurfaceComposerClient = sp<SurfaceComposerClient>::make();
ASSERT_EQ(NO_ERROR, mSurfaceComposerClient->initCheck());
mBackgroundLayer =
diff --git a/libs/gui/tests/SamplingDemo.cpp b/libs/gui/tests/SamplingDemo.cpp
index 8fea689c91..a2fe8fd2ec 100644
--- a/libs/gui/tests/SamplingDemo.cpp
+++ b/libs/gui/tests/SamplingDemo.cpp
@@ -36,7 +36,7 @@ namespace android {
class Button : public gui::BnRegionSamplingListener {
public:
Button(const char* name, const Rect& samplingArea) {
- sp<SurfaceComposerClient> client = new SurfaceComposerClient;
+ sp<SurfaceComposerClient> client = sp<SurfaceComposerClient>::make();
mButton = client->createSurface(String8(name), 0, 0, PIXEL_FORMAT_RGBA_8888,
ISurfaceComposerClient::eFXSurfaceEffect);
diff --git a/libs/gui/tests/Surface_test.cpp b/libs/gui/tests/Surface_test.cpp
index c479662b55..61c93cae14 100644
--- a/libs/gui/tests/Surface_test.cpp
+++ b/libs/gui/tests/Surface_test.cpp
@@ -134,7 +134,7 @@ protected:
}
virtual void SetUp() {
- mComposerClient = new SurfaceComposerClient;
+ mComposerClient = sp<SurfaceComposerClient>::make();
ASSERT_EQ(NO_ERROR, mComposerClient->initCheck());
// TODO(brianderson): The following sometimes fails and is a source of
diff --git a/opengl/tests/lib/WindowSurface.cpp b/opengl/tests/lib/WindowSurface.cpp
index e94b565f11..beac9001bc 100644
--- a/opengl/tests/lib/WindowSurface.cpp
+++ b/opengl/tests/lib/WindowSurface.cpp
@@ -29,7 +29,7 @@ using namespace android;
WindowSurface::WindowSurface() {
status_t err;
- sp<SurfaceComposerClient> surfaceComposerClient = new SurfaceComposerClient;
+ sp<SurfaceComposerClient> surfaceComposerClient = sp<SurfaceComposerClient>::make();
err = surfaceComposerClient->initCheck();
if (err != NO_ERROR) {
fprintf(stderr, "SurfaceComposerClient::initCheck error: %#x\n", err);
diff --git a/services/automotive/display/AutomotiveDisplayProxyService.cpp b/services/automotive/display/AutomotiveDisplayProxyService.cpp
index afa623352b..56c3b7d31f 100644
--- a/services/automotive/display/AutomotiveDisplayProxyService.cpp
+++ b/services/automotive/display/AutomotiveDisplayProxyService.cpp
@@ -65,7 +65,7 @@ AutomotiveDisplayProxyService::getIGraphicBufferProducer(uint64_t id) {
std::swap(displayWidth, displayHeight);
}
- sp<android::SurfaceComposerClient> surfaceClient = new SurfaceComposerClient();
+ sp<android::SurfaceComposerClient> surfaceClient = sp<SurfaceComposerClient>::make();
err = surfaceClient->initCheck();
if (err != NO_ERROR) {
ALOGE("SurfaceComposerClient::initCheck error: %#x", err);