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

Commit 153258f5 authored by Chavi Weingarten's avatar Chavi Weingarten Committed by Android (Google) Code Review
Browse files

Merge "Store last data received from WindowInfosListener" into tm-dev

parents ce3385d2 a2948ada
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -2320,9 +2320,11 @@ int SurfaceComposerClient::getGPUContextPriority() {
}

status_t SurfaceComposerClient::addWindowInfosListener(
        const sp<WindowInfosListener>& windowInfosListener) {
        const sp<WindowInfosListener>& windowInfosListener,
        std::pair<std::vector<gui::WindowInfo>, std::vector<gui::DisplayInfo>>* outInitialInfo) {
    return WindowInfosListenerReporter::getInstance()
            ->addWindowInfosListener(windowInfosListener, ComposerService::getComposerService());
            ->addWindowInfosListener(windowInfosListener, ComposerService::getComposerService(),
                                     outInitialInfo);
}

status_t SurfaceComposerClient::removeWindowInfosListener(
+14 −1
Original line number Diff line number Diff line
@@ -31,7 +31,8 @@ sp<WindowInfosListenerReporter> WindowInfosListenerReporter::getInstance() {

status_t WindowInfosListenerReporter::addWindowInfosListener(
        const sp<WindowInfosListener>& windowInfosListener,
        const sp<ISurfaceComposer>& surfaceComposer) {
        const sp<ISurfaceComposer>& surfaceComposer,
        std::pair<std::vector<gui::WindowInfo>, std::vector<gui::DisplayInfo>>* outInitialInfo) {
    status_t status = OK;
    {
        std::scoped_lock lock(mListenersMutex);
@@ -42,6 +43,11 @@ status_t WindowInfosListenerReporter::addWindowInfosListener(
        if (status == OK) {
            mWindowInfosListeners.insert(windowInfosListener);
        }

        if (outInitialInfo != nullptr) {
            outInitialInfo->first = mLastWindowInfos;
            outInitialInfo->second = mLastDisplayInfos;
        }
    }

    return status;
@@ -55,6 +61,10 @@ status_t WindowInfosListenerReporter::removeWindowInfosListener(
        std::scoped_lock lock(mListenersMutex);
        if (mWindowInfosListeners.size() == 1) {
            status = surfaceComposer->removeWindowInfosListener(this);
            // Clear the last stored state since we're disabling updates and don't want to hold
            // stale values
            mLastWindowInfos.clear();
            mLastDisplayInfos.clear();
        }

        if (status == OK) {
@@ -75,6 +85,9 @@ binder::Status WindowInfosListenerReporter::onWindowInfosChanged(
        for (auto listener : mWindowInfosListeners) {
            windowInfosListeners.insert(listener);
        }

        mLastWindowInfos = windowInfos;
        mLastDisplayInfos = displayInfos;
    }

    for (auto listener : windowInfosListeners) {
+4 −1
Original line number Diff line number Diff line
@@ -696,7 +696,10 @@ public:
    static status_t removeTunnelModeEnabledListener(
            const sp<gui::ITunnelModeEnabledListener>& listener);

    status_t addWindowInfosListener(const sp<gui::WindowInfosListener>& windowInfosListener);
    status_t addWindowInfosListener(
            const sp<gui::WindowInfosListener>& windowInfosListener,
            std::pair<std::vector<gui::WindowInfo>, std::vector<gui::DisplayInfo>>* outInitialInfo =
                    nullptr);
    status_t removeWindowInfosListener(const sp<gui::WindowInfosListener>& windowInfosListener);

protected:
+7 −3
Original line number Diff line number Diff line
@@ -34,15 +34,19 @@ public:
                                        const std::vector<gui::DisplayInfo>&,
                                        const sp<gui::IWindowInfosReportedListener>&) override;

    status_t addWindowInfosListener(const sp<gui::WindowInfosListener>& windowInfosListener,
                                    const sp<ISurfaceComposer>&);
    status_t addWindowInfosListener(
            const sp<gui::WindowInfosListener>& windowInfosListener, const sp<ISurfaceComposer>&,
            std::pair<std::vector<gui::WindowInfo>, std::vector<gui::DisplayInfo>>* outInitialInfo);
    status_t removeWindowInfosListener(const sp<gui::WindowInfosListener>& windowInfosListener,
                                       const sp<ISurfaceComposer>&);
                                       const sp<ISurfaceComposer>& surfaceComposer);
    void reconnect(const sp<ISurfaceComposer>&);

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

    std::vector<gui::WindowInfo> mLastWindowInfos GUARDED_BY(mListenersMutex);
    std::vector<gui::DisplayInfo> mLastDisplayInfos GUARDED_BY(mListenersMutex);
};
} // namespace android