Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c1b4af37 authored by Anton Ivanov's avatar Anton Ivanov
Browse files

Ensure libgui classes that are held by sp<> are only constructed with sp<>::make.

Exception is SurfaceComposerClient, which is widely references in vendor
code.

Test: presubmit
Flag: EXEMPT refactor
Bug: 393217449
Change-Id: Ib1039a1f7bc5676d32a4067361f131fc79efad4d
parent 4a95d2d9
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -36,8 +36,6 @@ class BufferQueueProducer : public BnGraphicBufferProducer {
public:
    friend class BufferQueue; // Needed to access binderDied

    explicit BufferQueueProducer(const sp<BufferQueueCore>& core,
                                 bool consumerIsSurfaceFlinger = false);
    ~BufferQueueProducer() override;

    // requestBuffer returns the GraphicBuffer for slot N.
@@ -219,6 +217,9 @@ public:
#endif

protected:
    explicit BufferQueueProducer(const sp<BufferQueueCore>& core,
                                 bool consumerIsSurfaceFlinger = false);
    friend class sp<BufferQueueProducer>;
    // see IGraphicsBufferProducer::setMaxDequeuedBufferCount, but with the ability to retrieve the
    // total maximum buffer count for the buffer queue (dequeued AND acquired)
    status_t setMaxDequeuedBufferCount(int maxDequeuedBuffers, int* maxBufferCount);
+4 −2
Original line number Diff line number Diff line
@@ -79,8 +79,6 @@ public:
    };
    static Context gChoreographers;

    explicit Choreographer(const sp<Looper>& looper, const sp<IBinder>& layerHandle = nullptr)
            EXCLUDES(gChoreographers.lock);
    void postFrameCallbackDelayed(AChoreographer_frameCallback cb,
                                  AChoreographer_frameCallback64 cb64,
                                  AChoreographer_vsyncCallback vsyncCallback, void* data,
@@ -113,6 +111,10 @@ public:

private:
    Choreographer(const Choreographer&) = delete;
    explicit Choreographer(const sp<Looper>& looper, const sp<IBinder>& layerHandle = nullptr)
            EXCLUDES(gChoreographers.lock);
    friend class sp<Choreographer>;
    friend AChoreographer* AChoreographer_create();

    void dispatchVsync(nsecs_t timestamp, PhysicalDisplayId displayId, uint32_t count,
                       VsyncEventData vsyncEventData) override;
+8 −6
Original line number Diff line number Diff line
@@ -23,12 +23,6 @@ using FrameRateOverride = DisplayEventReceiver::Event::FrameRateOverride;

class DisplayEventDispatcher : public LooperCallback {
public:
    explicit DisplayEventDispatcher(const sp<Looper>& looper,
                                    gui::ISurfaceComposer::VsyncSource vsyncSource =
                                            gui::ISurfaceComposer::VsyncSource::eVsyncSourceApp,
                                    EventRegistrationFlags eventRegistration = {},
                                    const sp<IBinder>& layerHandle = nullptr);

    status_t initialize();
    void dispose();
    status_t scheduleVsync();
@@ -38,6 +32,14 @@ public:
    status_t getLatestVsyncEventData(ParcelableVsyncEventData* outVsyncEventData) const;

protected:
    explicit DisplayEventDispatcher(const sp<Looper>& looper,
                                    gui::ISurfaceComposer::VsyncSource vsyncSource =
                                            gui::ISurfaceComposer::VsyncSource::eVsyncSourceApp,
                                    EventRegistrationFlags eventRegistration = {},
                                    const sp<IBinder>& layerHandle = nullptr);

    friend class sp<DisplayEventDispatcher>;

    virtual ~DisplayEventDispatcher() = default;

private:
+3 −0
Original line number Diff line number Diff line
@@ -40,6 +40,9 @@ public:
    void reconnect(const sp<gui::ISurfaceComposer>&);

private:
    WindowInfosListenerReporter() = default;
    friend class sp<WindowInfosListenerReporter>;

    std::mutex mListenersMutex;
    std::unordered_set<sp<gui::WindowInfosListener>, gui::SpHash<gui::WindowInfosListener>>
            mWindowInfosListeners GUARDED_BY(mListenersMutex);